JS验证码60秒倒计时源码

180it 2021-09-03 PM 1481℃ 0条

JS验证码60秒倒计时源码

<input id="btn" onclick="settime(this)" type="button" value="获取验证码" style="width: 6.125rem;height: 1.875rem;margin-top: -10.25rem;float: right;" />

<script type="text/javascript">
//验证码倒计时
var countdown=60;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled"); 
val.value="获取验证码";
countdown=60;
} else { 
val.setAttribute("disabled", true); 
val.value="重新发送(" + countdown + ")";
countdown--;
setTimeout(function(){
settime(val);
},1000) 
} }
</script>
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

JS验证码60秒倒计时源码