I wrote this a little while back:
Try it out and let me know if it works for you...Code:function Trim(strString){ //Trim() function removes spaces at either end //of the string and removes all extra spaces var strSplit; //Array of arg string split on spaces var strReturnString; //String to return // Split the string on all spaces. //All spaces are discarded and only //the characters remain. // /\s+/ is a Regular Expression that //represents a space character strSplit = strString.split(/\s+/); //Rejoin the string using a space. strReturnString = strSplit.join(" "); return strReturnString; }//end function





Reply With Quote