i have to create a website that has javascript that inputs a password, and checks for three things:
1)must be at least 8 characters
2)must contain one capital letter
and 3) must contain at least one number.
below is my code so far, but i cant seem to get the alert windows to pop up telling whether or not the password is valid. Any help is greatly appreciated.
[code=php]
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Exam Three Make Up</title>
<script type=”text/javascript”>
<!–
function Start()
{
var password;
var passwordArray = new Array(password.length);
var has8charicters = false;
var numeric = false;
var upperCase = false;
for(var i=0; i<password.length; i++)
{
passwordArray[i] =password.substring(i, i+1);
}
if(password.lenght>=8)
{
has8charicters = true;
numeric = checkNumeric(passwordArray);
upperCase = checkUpperCase(passwordArray);
}
if(has8chariters && numeric && upperCase)
{
alert(“vaild”)
}
else
{
alert(“not vaild”)
}
}
function checkNumeric(anArray)
{
for (var i =0; i<anArray.length; i++)
if(anArray[i]>=”0″ && anArray[i]<=”9″)
return true;
}
function checkUpperCase(anArray)
{
for(var i = 0; i<anArray.lenght; i++)
if(anArray[i]>=”A” && anArray[i]<=”z”)
return true;
}
//–>
</script>
</head>
<body>
<form name=”myForm” onSubmit=”Start()” action = “”>
<p>Please Enter your Password.<br />
<br />
Remember it should contain<br />
<br />
At least one capital letter<br />
<br />
And one number.<br />
<br />
<input name=”password” /> <input type=”Submit” value=”Submit” /></p>
</form>
</body>
</html>