首页 > 代码库 > 短信验证倒计时60s

短信验证倒计时60s

技术分享


$("#zphone").click(function(){ var tel2 = $("#regTel").val(); if(flag.tel){ $.post( "<%=path%>/main/login_regCode.action", {"tel":tel2}, function(data){ if(data){ if(data =http://www.mamicode.com/="has"){ RemainTime(); } } } ); return false; }else{ alert("必须为移动用户!"); } });var iTime = 59; var Account; function RemainTime(){ document.getElementById(‘zphone‘).disabled = true; var iSecond,sSecond="",sTime=""; if (iTime >= 0){ iSecond = parseInt(iTime%60); iMinute = parseInt(iTime/60); if (iSecond >= 0){ if(iMinute>0){ sSecond = iMinute + "分" + iSecond + "秒"; }else{ sSecond = iSecond + "秒"; } } sTime=sSecond; if(iTime==0){ clearTimeout(Account); sTime=‘获取手机验证码‘; iTime = 59; document.getElementById(‘zphone‘).disabled = false; }else{ Account = setTimeout("RemainTime()",1000); iTime=iTime-1; } }else{ sTime=‘没有倒计时‘; } document.getElementById(‘zphone‘).value = http://www.mamicode.com/sTime;"验证码超时!"); } }界面:
<li> <label>验 证 码: <input type="text" name="code" class="ipt" id="regCode"/> <input type="submit" id="zphone" value="http://www.mamicode.com/发送验证码" class="submitBtn1" /> <font color="#ff0000">* 不能为空</font> </label></li>

  

短信验证倒计时60s