Hello the code below checks if the email is real but when a real email is entered for some reason or another it states undefined when the sumit button is clicked even though the email entered is real. if no email is entered is says enter a an email, if a wrong email is entered it states no a vaild email. thats the only error but cant figure why its doing that any ideas guys
<HTML>
<HEAD>
<TITLE>Comment Form</TITLE>
<Script language = javascript>
function Validate() {
Message = ""
Message = Message + CheckEmail()
if (Message == "") {
return true
}
else {
alert(Message)
return false
}
}
function CheckEmail() {
email = document.f1.Email.value
AtPos = email.indexOf("@")
StopPos = email.lastIndexOf(".")
Message = ""
if (email == "") {
Message = "Not a valid Email address" + "\n"
return Message
}
if (AtPos == -1 || StopPos == -1) {
Message = "Not a valid email address" + "\n"
return Message
}
if (StopPos < AtPos) {
Message = "Not a valid email address" + "\n"
return Message
}
if (StopPos - AtPos == 1) {
Message = "Not a valid email address" + "\n"
return Message
}
}
</script>
</HEAD>
<BODY BGCOLOR = White>
<form name="f1" method="post" action="book.php" onSubmit="return Validate()" enctype = text/plain>
<tr>
<td height="40" valign="top" colspan="4" align="center"><b>Email:
<input type="text" name="Email" size="30">
</b></td>
</tr>
<tr align="center">
<td height="80" colspan="2" valign="top"> </td>
<td valign="top" colspan="3">
<input type="submit" name="Submit" value="Submit This Form">
<input type="reset" name="Submit2" value="Reset This Form">
</td>
</tr>
<tr>
<td height="0"></td>
<td width="40"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="1"></td>
<td></td>
<td width="10"></td>
<td></td>
<td></td>
</tr>
</table>
</form>
</BODY>
</HTML>