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, ' ');
return textValue;
}
0 comments:
Post a Comment
I love to entertain onymous user Comment !