Split string at index field length or just before that if there is white space I had to write a function to split a string that goes into a field if it(the string) were too long for the field, as it would disappear and be unreadable.

How's the code lookin' ?

function splitText(instr, fieldSize) //instr = string to split into two lines, fieldSize = the width(in characters)of the field where the string will be showing
{
    if(instr.length&gt;fieldSize) // Check if String requires splitting
    { 
        //If Yes split
        var firstLine = instr.substring(0,fieldSize);
        var secondLine = instr.substring(fieldSize);
        //Check some arbitrary number of characters towards the end if there is whiye space(5) Obviously too much would not look too good on teh webSite
        var firstLeft = firstLine.substring(0,13);
        var firstRight = firstLine.substring(13);
        if(firstRight.indexOf(' ')&gt;-1) 
            {
                //If There is white space, break the line at it
               instr = firstLeft+firstRight.substr(0,firstRight.indexOf(' '))+" \n"+firstRight.substr(firstRight.indexOf(' ')+1);
            }
        else
            //else just split the string, according to the field size
            instr = instr.substring(0,fieldSize)+"\n "+instr.substring(fieldSize);
        }

    return instr;
}
Your indentation is a bit off here, with the true case of the if being indented one extra level. The else case is missing its brackets, which is probably the cause of confusion.

    var firstRight = firstLine.substring(13);
    if(firstRight.indexOf(' ')&gt;-1) 
        {
            //If There is white space, break the line at it
           instr = firstLeft+firstRight.substr(0,firstRight.indexOf(' '))+" \n"+firstRight.substr(firstRight.indexOf(' ')+1);
        }
    else
        //else just split the string, according to the field size
        instr = instr.substring(0,fieldSize)+"\n "+instr.substring(fieldSize);
    }


Aside from that, you call firstRight.indexOf(' ') three times, and you'd be better off placing this in a separate variable.