Wednesday, June 19, 2013

Replace Line Break and Spaces on Text Area using java script !

Facebook

A simple way to replace line break and spaces on a text area content can be done simply by replacing the line break value and the space value with the corresponding html tag as following .

function replaceLineBreaksAndSpaces(textValue) {
   textValue = replaceSpaceCharacter(replaceLineBreak(textValue));
   return textValue;
}
   
function replaceLineBreak(textValue) {

    textValue = textValue.replace(/\r?\n/g, ' 
<br />');
    return textValue;

}

function replaceSpaceCharacter(textValue) {

    textValue = textValue.replace(/  /g, ' &nbsp;');
    return textValue;
}

0 comments:

Post a Comment

I love to entertain onymous user Comment !

Pages

 ©mytechtoday.com 2006-2010

 ©Mytechtoday.com, Learning from Experiences !

TOP