标签:style blog http ar io color os 使用 sp
Email验证
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>验证Email是否正确</title> <script language="javascript"> function checkemail(str){ //在JavaScript中,正则表达式只能使用"/"开头和结束,不能使用双引号 var Expression=/\w+([-+.‘]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; var objExp=new RegExp(Expression); if(objExp.test(str)==true){ return true; }else{ return false; } } function check(myform){ if(myform.email.value==""){ alert("请输入Email地址!");myform.email.focus();return; } if(!checkemail(myform.email.value)){ alert("您输入Email地址不正确!");myform.email.focus();return; } myform.submit(); } </script> </head> <body> <form name="form1" method="post" action=""> <table width="100%" height="276" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="16%" height="36" align="center">留言人:</td> <td width="84%"> <input name="author" type="text" id="author" size="30" title="留言人"></td> </tr> <tr> <td height="38" align="center">Email:</td> <td><input name="email" type="text" id="email" size="72" title="Email地址"> * </td> </tr> <tr> <td height="42" align="center"> </td> <td><input name="Submit" type="button" class="btn_grey" value="保存" onClick="check(form1)"> <input name="Submit2" type="reset" class="btn_grey" value="重置"> </td> </tr> </table> </form> </body> </html>
标签:style blog http ar io color os 使用 sp
原文地址:http://www.cnblogs.com/keyyang/p/4171863.html