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; }