I know its good to use serverside validation for security, except this is just to get my head around validation.
My efforts so far have amounted to the following
function validateUser()
{
var x=document.forms["myForm"]["email"].value;
var y=document.forms["myForm"]["password"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
var uppercase = password.match(/[A-Z]/)
var lowercase = password.match(/[a-z]/g)
var number = password.match(/[0-9]/g)
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address or password");
return false;
}else{
alert("Valid Email Address and Password");
return true;
}
}
Basically, I need an alert box to pop up when the password doesn't have at least 1 lowercase, uppercase and a number. So far my code is just throwing an error when the email is in the wrong format. What do I add to the if statement to check the password characters?
Thanks in advance,
James