欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js驗(yàn)證手機(jī)號(hào)、密碼、短信驗(yàn)證碼代碼工具類

 更新時(shí)間:2020年06月24日 16:02:53   作者:Joker_Ye  
這篇文章主要介紹了js驗(yàn)證手機(jī)號(hào)、密碼、短信驗(yàn)證碼代碼工具類,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了js驗(yàn)證手機(jī)號(hào)、密碼、短信驗(yàn)證碼的代碼工具類,供大家參考,具體內(nèi)容如下

代碼工具類

/** 
 * 參數(shù)較驗(yàn) 
 * 
 * */ 
var verification = { 
 stop : false, //倒計(jì)時(shí) 
 //驗(yàn)證手機(jī)號(hào) 
 phone : function (tel, id) { 
  if ("" == tel || !tel) { 
   mui.toast('手機(jī)號(hào)不可以為空!'); 
  } else { 
   var reg = /^0?1[3|4|5|7|8][0-9]\d{8}$/; 
   //驗(yàn)證規(guī)則 
   if (reg.test(tel)) return true; 
   mui.toast("手機(jī)號(hào)錯(cuò)誤!"); 
  } 
  document.getElementById(id).focus(); 
  return false; 
 }, 
 
 //驗(yàn)證密碼(密碼只能由數(shù)字和字母組成) 
 password : function (w, id) { 
  if ("" == w || !w) { 
   mui.toast('請(qǐng)輸入密碼!'); 
  } 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("密碼只能由數(shù)字和字母組成"); 
  } 
  document.getElementById(id).focus(); 
  return false; 
 }, 
 
 //驗(yàn)證碼倒計(jì)時(shí) 
 code : function (tel, btn, type) { 
  var that = this, 
   tel = $.trim(tel); 
  if (!this.phone(tel, 'userTel')) return false; 
  if (true == that.stop) return false; //防止重復(fù)點(diǎn)擊 
  that.stop = true; 
 
  var btn = $("#"+btn); 
  btn.attr("disabled", true).text("正在發(fā)送"); 
  var _no = 60; 
  var time = setInterval(function () { 
   _no--; 
   btn.text(_no + "秒后重發(fā)"); 
   if (_no == 0) { 
    //btn.attr("disabled", false).text("獲取驗(yàn)證碼"); 
    btn.removeAttr('disabled').text("重新獲取驗(yàn)證碼"); 
    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("獲取驗(yàn)證碼"); 
    that.stop = false; 
    _no = 60; 
    clearInterval(time); 
   } 
  }, 'json'); 
 } 
}; 

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論