jQuery判断邮箱格式对错实例代码讲解
废话不多说了,具体代码如下所示;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>检测Email地址格式是否正确</title> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <input type="text" id="emailname"> <input type="submit" value="检测Email地址格式是否正确" class="is-email"> <script type="text/javascript"> $(".is-email").click(function(){ var email = $("#emailname").val(); if(email == ''){ alert("请输入您的邮箱"); return; }else if(email != "") { var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; isok= reg.test(email ); if (!isok) { alert("邮箱格式不正确,请重新输入!"); return false; } }; alert("ok 输入正确"); }); </script> </body> </html>
相关推荐
88570299 2020-06-18
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18