Hi I have this code but no validation is done please help I am a bigginer in javascript.
<html>
<head>
<script language="javascript">
function display()
{
var pass = string(document.registration.password.value);
var confirmpass = sring(document.registration.confirmpassword.value);
if (pass != confirmpass)
{
alert("Password and Confirm Password must be the same"
return false;
}
If (isNaN(document.registration.phonenumber.value)==true)
{
alert("Phone number must be numbers"
return false;
}
If (isNaN(document.registration.age.value)==true)
{
alert("Age must be in number"
document.registration.age.focus();
return false;
}
If (isNaN(document.registration.zip.value)==true)
{
alert("Zip must be number"
return false;
}
}
</script>
</head>
<body>
<form method = "POST" name="registration" action = " onSubmit = "display()">
Username <input type ="text" name="username" size="30"><br>
Password <input type ="text" name="password" size="30"><br>
Confirm Password <input type ="text" name="confirmpassword" size="30"><br>
Age <input type ="text" name="age" size="2"><br>
Sex <select name="sex" size="1"><br>
<option>Female
<option>Male
</select><br>
Address <input type ="text" name="address" size="30"><br>
Phone Number <input type ="text" name="phonenumber" size="30"><br>
Country <select name="country" size="1"><br>
<option>Tanzania
<option>Kenya
<option>Uganda
<option>Zambia
<option>Zimbabwe
<option>Mozambique
</select><br>
Zip Code <input type ="text" name="zip" size="30"><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
<html>
<head>
<script language="javascript">
function display()
{
var pass = string(document.registration.password.value);
var confirmpass = sring(document.registration.confirmpassword.value);
if (pass != confirmpass)
{
alert("Password and Confirm Password must be the same"
return false;
}
If (isNaN(document.registration.phonenumber.value)==true)
{
alert("Phone number must be numbers"
return false;
}
If (isNaN(document.registration.age.value)==true)
{
alert("Age must be in number"
document.registration.age.focus();
return false;
}
If (isNaN(document.registration.zip.value)==true)
{
alert("Zip must be number"
return false;
}
}
</script>
</head>
<body>
<form method = "POST" name="registration" action = " onSubmit = "display()">
Username <input type ="text" name="username" size="30"><br>
Password <input type ="text" name="password" size="30"><br>
Confirm Password <input type ="text" name="confirmpassword" size="30"><br>
Age <input type ="text" name="age" size="2"><br>
Sex <select name="sex" size="1"><br>
<option>Female
<option>Male
</select><br>
Address <input type ="text" name="address" size="30"><br>
Phone Number <input type ="text" name="phonenumber" size="30"><br>
Country <select name="country" size="1"><br>
<option>Tanzania
<option>Kenya
<option>Uganda
<option>Zambia
<option>Zimbabwe
<option>Mozambique
</select><br>
Zip Code <input type ="text" name="zip" size="30"><br><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>