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();
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: How to use trim function in javascript, Trim function in javascript, Trim in javascript