<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
var wait=60;
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value="免费获取验证码";
wait = 60;
} else {
o.setAttribute("disabled", true);
o.value="重新发送(" + wait + ")";
wait--;
setTimeout(function() {
time(o)
},
1000)
}
}
document.getElementById("btn").onclick=function(){time(this);}
</script>验证码60秒禁用
最新推荐文章于 2022-08-21 22:31:25 发布
本文介绍了一种使用JavaScript实现的验证码按钮倒计时功能,该功能能够在用户点击按钮请求验证码后启动倒计时,限制用户在一定时间内无法重复请求,直至倒计时结束。通过设置按钮的状态和显示文本变化,提供了良好的用户体验。
903

被折叠的 条评论
为什么被折叠?



