The custom trim function :
function trim (str) {Typical use of trim :
var str = str.replace(/^\s\s*/, ''),
ws = /\s/,
i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
function validate()Surely if you use any rich javascript library a trim method should come with it. Have fun :)
{
val = document.getElementById("txt").value;
retval = trim12(val);
alert(retval);
}
No comments:
Post a Comment