标签:asc als blog jquer set src function html pre
<!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>
标签:asc als blog jquer set src function html pre
原文地址:http://www.cnblogs.com/wangjae/p/6693992.html