本文实例为大家分享了js验证手机号、密码、短信验证码的代码工具类,供大家参考,具体内容如下
代码工具类
错误!");
}
document.getElementById(id).focus();
return false;
},//验证密码(密码只能由数字和字母组成)
password : function (w,id) {
if ("" == w || !w) {
mui.toast('请输入密码!');
} else if (w.length < 6) {
mui.toast('密码至少大于等于6位!');
} else if (w.length > 20) {
mui.toast('密码不能超过20位!');
} else if (w) {
var reg = /^[0-9a-zA-Z]+$/;
if (reg.test(w)) return true;
mui.toast("密码只能由数字和字母组成");
}
document.getElementById(id).focus();
return false;
},//验证码倒计时
code : function (tel,btn,type) {
var that = this,tel = $.trim(tel);
if (!this.phone(tel,'userTel')) return false;
if (true == that.stop) return false; //防止重复点击
that.stop = true;
原文链接:https://www.f2er.com/js/42247.htmlvar btn = $("#"+btn);
btn.attr("disabled",true).text("正在发送");
var _no = 60;
var time = setInterval(function () {
_no--;
btn.text(_no + "秒后重发");
if (_no == 0) {
//btn.attr("disabled",false).text("<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>验证码");
btn.removeAttr('disabled').text("重新<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>验证码");
that.stop = false;
_no = 60;
clearInterval(time);
}
},1000);
var url = "/Home/User/sendVerifyCode.html";
$.post(url,{
toNumber: tel,type:type
},function (result) {
mui.toast(result.info);
if (200 != result.status) {
btn.removeAttr('disabled').text("<a href="https://www.jb51.cc/tag/huoqu/" target="_blank" class="keywords">获取</a>验证码");
that.stop = false;
_no = 60;
clearInterval(time);
}
},'json');
}
};