Let's talk about the following code:
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> email verification </title>
</Head>
<Body>
<Script language = "JavaScript">
<! --
Function check ()
{
If (document. Register. Email. value. length! = 0)
{
If (document. Register. Email. value. charat (0) = "." |
Document. Register. Email. value. charat (0) = "@" |
Document. Register. Email. value. indexof ('@', 0) =-1 |
Document. Register. Email. value. indexof ('.', 0) =-1 |
Document. Register. Email. value. lastindexof ("@") = Document. Register. Email. value. Length-1 |
Document. Register. Email. value. lastindexof (".") = Document. Register. Email. value. Length-1)
{
Alert ("the email format is incorrect! ");
Document. Register. Email. Focus ();
Return false;
}
}
Else
{
Alert ("email cannot be blank! ");
Document. Register. Email. Focus ();
Return false;
}
Return false;
}
// -->
</SCRIPT>
<Form name = "register" method = "Post" Action onsubmit = "Return check ();">
<P align = "center">
Email: <input type = "text" name = "email" size = "20">
<Input type = "Submit" value = "Submit" name = "B1">
<Input type = "reset" value = "Refill" name = "B2">
</P>
</Form>
</Body>
</Html>