用正则检测邮箱名
发布时间:2020-12-14 00:42:32 所属栏目:百科 来源:网络整理
导读:!DOCTYPE htmlhtmlheadtitle检测邮箱名/titlemeta charset="utf-8"/headbodyinput type="test" name="" id="email" !--设置Email输入框-- input type="button" name="" value="检测合法性" onclick="checkEmail()" !--checkEmail后不要忘了()-- script typ
<!DOCTYPE html> <html> <head> <title>检测邮箱名</title> <meta charset="utf-8"> </head> <body> <input type="test" name="" id="email" > <!--设置Email输入框--> <input type="button" name="" value="检测合法性" onclick="checkEmail()"> <!--checkEmail后不要忘了()--> <script type="text/javascript"> function checkEmail(){ var objStr = document.getElementById("email").value; //不要忘了.value var objReg = /w+[@]{1}w+[.]{1}w+/; if(objReg.test(objStr)){ alert("输入的邮箱是符合标准的"); }else{ alert("输入的邮箱不符合标准"); } } </script> </body> </html> 正则表达式可参考: http://blog.csdn.net/leledexixi/article/details/54831141 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |