Thursday, April 16, 2009

Formatting text on Textarea/ Remove unwanted chars in Textarea

function escapeVal(textarea,replaceWith){

textarea.value = escape(textarea.value);

for(i=0; i<textarea.value.length; i++){

if(textarea.value.indexOf("%0D%0A") > -1){

textarea.value=textarea.value.replace("%0D%0A",replaceWith)

}

else if(textarea.value.indexOf("%0A") > -1){

textarea.value=textarea.value.replace("%0A",replaceWith)

}

else if(textarea.value.indexOf("%0D") > -1){

textarea.value=textarea.value.replace("%0D",replaceWith)

}

}

return unescape(textarea.value);

}


If you need to remove un wanted chars in a textarea you can use the above java script.

parameters
----------

set the textarea object as the 1st parameter and 2nd paramter is the replaceable char with unwanted ones.

No comments:

Post a Comment