Trim Leading and Trailing Spaces of Field Value

Mindwatering Incorporated

Author: Tripp W Black

Created: 08/23/2009 at 06:20 PM

 

Category:
Notes Developer Tips
JavaScript

Issue:
Need to remove spaces users inadvertently leave in fields.

Solution:
Add the following function to your JSHeader:

function DoTrim(fldval) {
return(fldval.replace(/^\s+|\s+$/g, ''));
}

Call it with:
this.value = DoTrim(this.value);


To Trim ALL spaces out of field:
function DoFullTrim(fldval) {
return fldval.split(' ').join('');
}


Call it with:
this.value = DoFullTrim(this.value);



previous page