Trim whitespace from a string in Javascript:
String.prototype.trim = function() { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }
Test test testing