My java scirpt is not working right. It is simple pre-vailidation form and I can not get the script to work. It is supposed to validate each field but I can not get it to validate past the first name. I stripped out all of the other garbage so the code would not be confusing Should be a copy paste to notepad. Little help please
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript" type="text/javascript">
<!--
function validateForm(theForm) {
var name = theForm.firstname.value;
var name = theForm.lastname.value;
var email = theForm.email.value;
if (name == "") {
alert("Please fill in your First Name.");
theForm.firstname.focus();
return false;
}
if (name == "") {
alert("Please fill in your Last Name.");
theForm.lastname.focus();
return false;
}
if (email == "") {
alert("Please fill in your email address.");
theForm.email.focus();
return false;
}
return true;
}
//-->
</script>
if (!theForm.myCheckbox1.checked {
alert("Please check the honor box.");
return false;
}
</head>
<body>
</script>
<fieldset>
<legend>Fun in the Sun With JavaScirpt</legend>
<ul>
<form action="blah.cgi" method="post"
onSubmit="return validateForm(this);">
First name: <input type="text" name="firstname"> <font color="#FF0000" size="1" face="Arial, Helvetica, sans-serif"><strong>*</strong></font> <br><br>
Last name: <input type="text" name="lastname"> <font color="#FF0000" size="1" face="Arial, Helvetica, sans-serif"><strong>*</strong></font> <br><br>
Email address: <input type="text" name="email"> <font color="#FF0000" size="1" face="Arial, Helvetica, sans-serif"><strong>*</strong></font> <br><br>
Phone Number: <input type="text" name="phone"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
<input type="checkbox" name="myCheckbox" value="someValue"><font color="#FF0000" size="1" face="Arial, Helvetica, sans-serif"><strong>*</strong></font> <P>By checking this Box you are confirming the data is accurate</p>
<p>(* indicates a required field)</p>
</body>
</html>