1 <HTML>2 <Head>3 <Metahttp-equiv= "Content-type"content= "text/html; charset=gb2312" />4 <title>Verify email is correct</title>5 <Scriptlanguage= "JavaScript">6 functionCheckemail (str) {7 //in JavaScript, regular expressions can only start and end with "/" and cannot use double quotation marks8 varExpression=/\w+ ([-+. '] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) */; 9 varObjexp=NewRegExp (Expression);Ten if(Objexp.test (str)==true){ One return true; A }Else{ - return false; - } the } - functionCheck (myform) { - if(Myform.email.value==""){ - Alert ("Please enter your email address!"); Myform.email.focus ();return; + } - if(!Checkemail (Myform.email.value)) { + Alert ("you entered the email address is not correct!"); Myform.email.focus ();return; A } at myform.submit (); - } - </Script> - </Head> - <Body> - <formname= "Form1"Method= "POST"Action=""> in <Tablewidth= "100%"Height= "276"Border= "0"cellpadding= "0"cellspacing= "0"> - <TR> to <TDwidth= "16%"Height= "The "Align= "Center">Message Person:</TD> + <TDwidth= "84%"> - <inputname= "Author"type= "text"ID= "Author"size= "+"title= "message Person"></TD> the </TR> * <TR> $ <TDHeight= "$"Align= "Center">Email:</TD>Panax Notoginseng <TD><inputname= "Email"type= "text"ID= "Email"size= " the"title= "Email address"> - </TD> the </TR> + <TR> A <TDHeight= " a"Align= "Center"> </TD> the <TD><inputname= "Submit"type= "button"class= "Btn_grey"value= "Save"OnClick= "Check (form1)"> + - <inputname= "Submit2"type= "Reset"class= "Btn_grey"value= "Reset"> </TD> $ </TR> $ </Table> - </form> - </Body> the </HTML>
Note: Regular expressions can only start and end with "/" and cannot use double quotes, so you should pay attention when you write the regular.