Stated Javascript yesterday. I am writing client side form validation using JavaScript and am using a bunch of if statements for my code.
This is it so fa.:
function validateloginform() { //login page validation test //
var username = document.forms["form"]["username"].value;
var password = document.forms["form"]["password"].value;
var verifypassword = document.forms["form"]["verifypassword"].value;
if (document.form.username.value == null || document.form.username.value == "") {
alert("Username is blank...it must be entered");
document.form.username.focus();
return false;
}
if (document.form.username.value.length != 8) {
alert("Username must be 8 characters long");
document.form.username.focus();
return false;
} else {
alert("Correct");
return true;
}
}
How can I be more specific with my statements to include combination of numerical and alphabetical ([a-z] or [0-9]) characters.
If if the username or password do not contain a combination of letters and numbers return false. Also, is there any way to include special characters?