admin管理员组文章数量:1312861
I have a form with a submit button. I want to disable the submit button for 10 seconds, and show a countdown, at the end of which the button bees clickable.
How would I do that? Im using jquery on the site, but Im not a JS programmer.
I have a form with a submit button. I want to disable the submit button for 10 seconds, and show a countdown, at the end of which the button bees clickable.
How would I do that? Im using jquery on the site, but Im not a JS programmer.
Share Improve this question asked Aug 28, 2010 at 3:01 user15063user15063 1- No everyone has a luxury of delegating different tasks to different programmers. – user15063 Commented Aug 28, 2010 at 17:10
1 Answer
Reset to default 8Let's keep it simple. If you'd like an explanation of what is going on, let me know:
<html>
<head>
<script type="text/javascript">
setTimeout (function(){
document.getElementById('submitButton').disabled = null;
},10000);
var countdownNum = 10;
incTimer();
function incTimer(){
setTimeout (function(){
if(countdownNum != 0){
countdownNum--;
document.getElementById('timeLeft').innerHTML = 'Time left: ' + countdownNum + ' seconds';
incTimer();
} else {
document.getElementById('timeLeft').innerHTML = 'Ready!';
}
},1000);
}
</script>
</head>
<body>
<form>
<input type="submit" disabled="disabled" id="submitButton" />
<p id="timeLeft">Time Left: 10 seconds</p>
</form>
</body>
</html>
本文标签: javascriptHow to disable form button click function for X secondsStack Overflow
版权声明:本文标题:javascript - How to disable form button click function for X seconds - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741909989a2404384.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论