Trim spaces from starting and ending of string using javascript
function removeSpace ()
{
var str=document.getElementById("tex").value;
str[t] = str[t].replace(/^\s+/, '');
for (var i = str.length - 1; i >= 0; i--) {
if (/\S/.test(str.charAt(i))) {
str = str.substring(0, i + 1);
break;
}
}
}
return str;
}
0 comments:
Post a Comment