Hello everyone i’m having a bit of trouble with the password field i for a login page. I want the Password field to have at least 1 Upper Casse Letter and i don’t know how to add the restrictions [/W]. The javascript code i use can be found here. [URL=”http://www.webcheatsheet.com/javascript/form_validation.php”]http://www.webcheatsheet.com/javascript/form_validation.php
[CODE]function validateFormOnSubmit(theForm) {
var reason = “”;
reason += validateUsername(theForm.username);
reason += validatePassword(theForm.password);
if (reason != “”) {
alert(“In order for you to login please fill in the following:n” + reason);
return false;
}
return true;
function validatePassword(fld) {
var error = “”;
var illegalChars = /[W_]/; // this allows only letters and numbers – I want it to also check for at least 1 Upper Case letter.
if (fld.value == “”) {
fld.style.background = ‘Yellow’;
error = “You must enter the password.n”;
} else if ((fld.value.length < 7) || (fld.value.length > 18)) {
error = “You must enter the password.n”;
fld.style.background = ‘Yellow’;
} else if (illegalChars.test(fld.value)) {
error = “Please enter a valid password.n”;
fld.style.background = ‘Yellow’;
} else {
fld.style.background = ‘White’;
}
return error;
}
}
Thanks in advance !