02-07-2008

Javascript Javascript trim function

The javascript string object lacks a native leading / trailing white-space stripping method. The following function does the job.

function trim(stringValue) {
  stringValue= stringValue.replace(/^\s+/,'');
  stringValue= stringValue.replace(/\s+$/,'');
  return stringValue;
}

Comments:

Your comment:

»

 

[x]