I made the following funcs based on the logic in Bodie's post:
function LTrim (s){
//trim lefthand spaces
while(''+s.charAt(0)==' ') {
s = s.substring(1,s.length-1);
}
return s;
}
function RTrim (s){
//trim righthand spaces
if (s.length > 1) {
while(''+s.charAt(s.length-1)==' ') {
s = s.substring(0,s.length-2);
}
return s;
}
}
+++++++++++++++++++++++++++++++++++++++++++
Originally posted by Bodie Minster:
[B]I found the following script at javascript.internet.com:
This snippet just rebuilds your string, one character at a time, leaving out the leading spaces. You could do something similar for trailing spaces.[/B]