js提交表单的时候,30秒后才能提交第二次
Posted 风意不止
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js提交表单的时候,30秒后才能提交第二次相关的知识,希望对你有一定的参考价值。
如何禁用提交按钮?禁用的表单样式怎么写?
如何30秒后可以提交?
百度了很多,找到了一个最简单的代码
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js点击按钮后,倒计时N秒后才能再次点击提交</title>
</head>
<body>
<input type="button" id="btn" value="免费获取验证码" />
<script type="text/javascript">
var wait = 60;
function time(obj) {
if (wait == 0) {
obj.removeAttribute("disabled");
obj.value = "免费获取验证码";
wait = 60;
} else {
obj.setAttribute("disabled", true);
obj.value = "重新发送(" + wait + ")";
wait--;
setTimeout(function () {
time(obj)
},
1000)
}
}
document.getElementById("btn-form1").onclick = function () { time(this); }
</script>
</body>
</html>
以上是关于js提交表单的时候,30秒后才能提交第二次的主要内容,如果未能解决你的问题,请参考以下文章
Ajax 表单提交在第一次提交时返回错误,但在第二次单击时提交
使用 .on 和 .validate 的 jQuery 必须提交两次表单才能验证