.Net Links

Thursday, January 20, 2011

Trim function in Javascript

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

function trim() {
return this.replace(/^\s+|\s+$/g, '');
}
Add the above lines and call the trim function which would trim the leading and trailing spaces in the variable Password


var Password = document.getElementById('ctl00_cphBody_txtPassword').value;
Password = Password.trim();

Labels: , ,