javascript 正则表达式邮箱验证
示例代码如下:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <html> <head> <mce:script language="Javascript1.2"><!-- function verifyAddress(obj) { var email = obj.email.value; var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; flag = pattern.test(email); if(flag) { alert("恭喜您!您填写的邮箱地址是正确的!"); return true; } else { alert("请再试一次"); return false; } } // --></mce:script> </head> <body> <form onSubmit="return verifyAddress(this);"> <input name="email" type="text"> <input type="submit"> </form> </body> </html>
原文来自http://blog.csdn.net/cyanapple_wen/article/details/5421412