国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

js驗證手機號、密碼、短信驗證碼代碼工具類

2019-11-19 17:49:59
字體:
來源:轉載
供稿:網友

本文實例為大家分享了js驗證手機號、密碼、短信驗證碼的代碼工具類,供大家參考,具體內容如下

代碼工具類

/**  * 參數較驗  *  * */ var verification = {   stop : false, //倒計時   //驗證手機號   phone : function (tel, id) {     if ("" == tel || !tel) {       mui.toast('手機號不可以為空!');     } else {       var reg = /^0?1[3|4|5|7|8][0-9]/d{8}$/;       //驗證規則       if (reg.test(tel)) return true;       mui.toast("手機號錯誤!");     }     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;      var 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("獲取驗證碼");         btn.removeAttr('disabled').text("重新獲取驗證碼");         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("獲取驗證碼");         that.stop = false;         _no = 60;         clearInterval(time);       }     }, 'json');   } }; 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云和县| 江都市| 纳雍县| 雅安市| 余姚市| 神木县| 江津市| 长乐市| 宜良县| 聂拉木县| 太保市| 连山| 安顺市| 桓仁| 四会市| 昌邑市| 甘孜| 瓮安县| 盘山县| 施甸县| 潼关县| 柯坪县| 海淀区| 凌源市| 琼中| 阜平县| 饶阳县| 阿勒泰市| 丰镇市| 屯留县| 牟定县| 安化县| 扎赉特旗| 榆林市| 宁津县| 安康市| 甘孜县| 河东区| 台东市| 钟山县| 雷波县|