傳送簡訊驗證碼後60秒倒計時
阿新 • • 發佈:2018-12-09
jquery實現的傳送簡訊驗證碼後60秒倒計時功能,完整例項可到http://smsow.zhenzikj.com/doc/sdk.html 下載"註冊驗證碼"的demo。
直接下載:
java版: http://smsow.zhenzikj.com/demo/download.html?fileName=zhenzisms_java_demo
php版: http://smsow.zhenzikj.com/demo/download.html?fileName=zhenzisms_php_demo
效果圖:
javascript原始碼
//簡訊驗證碼倒計時 var countdownHandler = function(){ var $button = $(".sendVerifyCode"); var number = 60; var countdown = function(){ if (number == 0) { $button.attr("disabled",false); $button.html("傳送驗證碼"); number = 60; return; } else { $button.attr("disabled",true); $button.html(number + "秒 重新發送"); number--; } setTimeout(countdown,1000); } setTimeout(countdown,1000); }
html原始碼
<body> <form> <div class="row"> <label>賬號: </label><input name="userId"> </div> <div class="row"> <label>密碼:</label><input name="password"> </div> <div class="row"> <label>手機號:</label><input name="mobile"> </div> <div class="row"> <label>驗證碼:</label> <input name="verifyCode"> <button type="button" class="sendVerifyCode">獲取簡訊驗證碼</button> </div> <div><button type="button" class="sub-btn">提交</button></div> </form> </body>