Remove Carriage Returns from TextArea Field with JavaScript

Mindwatering Incorporated

Author: Tripp W Black

Created: 02/12/2011 at 11:55 AM

 

Category:
Notes Developer Tips
JavaScript

Issue:
Need client side Javascript to remove multiple spaces and returns in a Text Area box.

Solution:

Call the function below in the onChange or onKeyUp event:
return TrimFormatting(this)

function TrimFormatting(curFld) {
      curFld.value=curFld.value.replace(/ {2,}/g,' ').replace(/[\n\r]*/g,'');
}



previous page