The question says it all; JS doesn\'t seem to have a native trim() method.
You can use following ...
function trim(str) { try { if (str && typeof(str) == 'string') { return str.replace(/^\s*|\s*$/g, ""); } else { return ''; } } catch (e) { return str; } }