国产探花免费观看_亚洲丰满少妇自慰呻吟_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');   } }; 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石渠县| 青河县| 德昌县| 三原县| 调兵山市| 来安县| 陕西省| 青阳县| 遂昌县| 乐山市| 哈密市| 定日县| 尼木县| 乡城县| 辽宁省| 皋兰县| 西华县| 奇台县| 周口市| 思茅市| 叶城县| 岳西县| 德保县| 泾川县| 海林市| 思南县| 彭水| 察隅县| 衡阳县| 华亭县| 宜宾县| 山东省| 壶关县| 蛟河市| 柘城县| 安义县| 苗栗县| 四平市| 留坝县| 慈利县| 和平县|