Your answer
<HTML>
<HEAD>
<TITLE>Comment Form</TITLE>
<Script language = javascript>
function Validate() {
var 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
}
return Message
}
</script>
</HEAD>
<BODY BGCOLOR = red>
<form name="f1" method="post" action="book.php" onSubmit="return Validate()" enctype = text/plain>
<table width="709">
<tr><td height="40" valign="top" colspan="4" align="center"><b>Email:<input type="text" name="Email" size="30"></b></td><td height="80" colspan="2" valign="top"><input type="submit" name="Submit" value="Submit This Form"></td>
<td valign="top" colspan="3"><input type="reset" name="Submit2" value="Reset This Form"></td></tr>
</table>
</form>
</BODY>
</HTML> nikesh.yadav
Posting Whiz in Training
219 posts since Feb 2008
Reputation Points: 15
Solved Threads: 21