<div class= "Input-group" id= "Login_do" ><input type= "num" class= "Form-control inputd" id= "TelCode" Placeholder= "SMS Verification Code"/><span class= "Input-group-addon input-span-black" style= "Display:none" >120s after re-acquisition < /span><span class= "Input-group-addon input-span-white" > </span><a href= "javascript: void (0) "id=" Getcaptcha "class=" Input-group-addon input-span-orange "> Get SMS Verification Code </a><input type=" hidden " Value= "1" name= "Start" id= "Start"/><span class= "Input-group-addon input-span-white" > </span ></div>
<script type= "Text/javascript" > var start = document.getElementById (' Start ') .value; var getcaptcha = document.getElementById (' Getcaptcha '); Var login_do = document.getelementbyid (' Login _do ') ;start = 0; $ (function () { if (start == 1) { startexcute ();}}) Var wait = 120;function timecaptcha (obj) { if (wait == 0) { obj.setattribute (" Disabled ", false); obj.innerhtml= "Resend"; login_do.style.background = "#ff7c8a"; login_do.style.boxShadow = "0 5px 0 0 # e9717e "; getcaptcha.style.color = "#fff"; wait = 120; } else { obj.innerHTML= wait + "Resend after second"; obj.setattribute ("Disabled", true); wait--; settimeout (function () { &Nbsp; timecaptcha (obj) }, 1000); getCaptcha.onclick = null; } if ( obj.innerhtml == "Resend") { getcaptcha.onclick = function () { obj.innerhtml= wait + " Seconds to Resend "; login_do.style.background = " #dbdbdb "; login_do.style.boxShadow = "0 5px 0 0 #cbcbcb "; getcaptcha.style.color = "#000"; //obj.setattribute ("Disabled", true); settimeout (function () { timecaptcha (obj) }, 1000); getcaptcha.onclick = null; Resendcaptcha (); } } }getcaptcha.onclick = function () {Timecaptcha (this);} Function startexcute () {getcaptcha.innerhtml= wait + "resend in Seconds"; Getcaptcha.setattribute ("Disabled", true); wait--; settimeout (function () { timecaptcha (Getcaptcha) }, 1000); getcaptcha.onclick = null;} Function resendcaptcha () {var phone = $ ("#phone"). Val (); var url = "{: U (' Register/ajaxsendcode ')}", $.post (url,{phone:phone},function (data) {/*alert (data) if (data.error != 0 ) { showalert ("Zhezhao2", "ShowDiv2", "zhe2"); }*/}, ' JSON '); return false;}
This article is from the "Day South Side" blog, please make sure to keep this source http://phpnan.blog.51cto.com/2641199/1657991
JS SMS Verification Code Countdown effect