Trimming strings with Javascript
Here is a quick code snippet showing how you can trim strings in javascript:
function trim(trimThis) {
return trimThis.replace(/^\s+|\s+$/g,"");
}
// left trim function ltrim(trimThis) {
return trimThis.replace(/^\s+/,"");
}
// right trim function rtrim(trimThis) {
return trimThis.replace(/\s+$/,"");
}
Example:
var thisString = " welcome to my blog ";
alert(trim(thisString));
...





JavaScript Library of ColdFusion Functions
"This is a JavaScript library that emulates many ColdFusion functions. It is useful for ColdFusion developers who are new to JavaScript or who want to maintain consistency in a ColdFusion and JavaScript mixed application. It is also useful for developers who prefer the ColdFusion (and Visual Basic) syntax of invoking functions."
http://www.leftcorner.com/index.cfm?Article=JavaSc...
String.prototype.trim = function() {
return this.replace(/^\s*|\s*$/g, "")
}
then you can use it just like this:
alert(myString.trim());
etc..