If you add these three lines of script before you need the functions then you can use lTrim, rTrim and trim functions:
Code:
String.prototype.lTrim = function(){return this.replace(/^\s*/g,"");}
String.prototype.rTrim = function(){return this.replace(/\s*$/g,"");}
String.prototype.trim = function(){return this.lTrim().rTrim();}
Examples:
Code:
var s = " Using trim functions ";
alert("lTrim: !" + s.lTrim() + "!");
alert("rTrim: !" + s.rTrim() + "!");
alert("trim: !" + s.trim() + "!");
--
Joe (
Microsoft MVP - XML)