jquery表单验证实例仿Toast提示效果
HTML内容部分
<div class="classname"> <label for="">请输入您的手机号码</label> <input type="text" id="MobilePhone"/> <input type="text" /> --> </div>
提示html及样式部分
<div id="errormsg" style="display: none;"></div> <style> #errormsg{ width: auto; height: 20px; padding: 1px 5px; text-align: center; background-color: #000; opacity: 0.5; color: #fff; position: fixed; left: 50%; margin-left: -50px; top: 93%; border-radius: 20px; } </style>
jquery表单验证(正则表达式)
//验证手机号码 $("#MobilePhone").blur(function(){ var tel = $("#MobilePhone").val();//获取输入的手机号 var yidongreg = /^(134[012345678]\d{7}|1[34578][012356789]\d{8})$/; var dianxinreg = /^1[3578][01379]\d{8}$/; var liantongreg = /^1[34578][01256]\d{8}$/; if (yidongreg.test(tel) || dianxinreg.test(tel) || liantongreg.test(tel)) { $("errormsg").css({"display":"block"}); $("#errormsg").html("请输入正确号码").fadeIn(300).delay(2000).fadeOut(300); }else{ $("errormsg").css({"display":"block"}); $("#errormsg").html("请输入正确号码").fadeIn(300).delay(2000).fadeOut(300); } });
相关推荐
tztzyzyz 2020-07-20
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
83510998 2020-07-18
81463166 2020-07-17