Hbuilder MUI 注冊短信驗證60秒后重新發送


<div class="mui-input-row">

<label class="iconfont_log_reg icon-youjian"></label>
<input type="text"  placeholder="請輸入短信驗證碼" id="u_code">
<a href="javascript:senmobile(60);" id="get_code" disabled="true">獲取驗證碼</a>
</div>
/www.bcty365.com 
var issend=true;
function senmobile(t) 

if(issend){ 

//驗證電話號碼手機號碼 

var phoneObj = document.getElementById('phone'); 

var pw = document.getElementById('passw'); 

var get_code=document.getElementById('get_code'); 

if (phoneObj.value != ""){  

var phoneVal=phoneObj.value;  

var p1 = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;  

var me = false;  

if (p1.test(phoneVal)) me=true;  

if (!me){  

            phoneObj.value='';  

     mui.toast('請輸入正確的手機號碼'); 

         phoneObj.focus();  

return false;  

     }else if(pw.length<6){ 

           mui.toast('密碼長度不夠6'); 

return false;  

      }else{ 

  1.             issend=false;   JKD.ajax({ 
  2.         url:"api_user.php?act=sendmobileregister", 
  3.                   dataType:"text", 
  4.                   type:"POST", 
  5.                   data:{'mobile':phoneObj.value}, 
  6.                   success:function(data){ 
  7. if(data == '1'){ 
  8.                         plus.nativeUI.toast('用戶已存在!', {verticalAlign: 'center'}); 
  9. return false; 
  10.                        } 
  11. var arr = data.split(","); 
  12. if(arr[1] == '0'){ 
  13.                          plus.nativeUI.toast('驗證碼發送成功!', {verticalAlign: 'center'}); 
  14.                         }else{ 
  15.                             plus.nativeUI.toast('驗證碼發送失敗!', {verticalAlign: 'center'}); 
  16.                         } 
  17. for(i=1;i<=t;i++) {  
  18.                             window.setTimeout("update_a(" + i + ","+t+")", i * 1000);  
  19.                         }  
  20.                   } 
  21.             }); 
  22.         } 
  23.     }else{ 
  24.         plus.nativeUI.toast('手機號碼不能為空!', {verticalAlign: 'center'}); 
  25. return false; 
  26.     } 
  27. function update_a(num,t) {  
  28. var get_code=document.getElementById('get_code'); 
  29. if(num == t) {  
  30.         get_code.innerHTML =" 重新發送 ";  
  31.         issend=true;  
  32.     }  
  33. else {  
  34. var printnr = t-num;  
  35.         get_code.innerHTML =printnr +" 秒后重發";  
  36.     }  
  37. }  

 

 

來源:http://www.bcty365.com/content-146-3101-1.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM