JavaScript实现点击按钮后变灰避免多次重复提交

时间:2013-07-15    点击:132   
注册的时候需要发送验证激活帐号的邮件,为了避免邮件的多次重复发送,所以可以在点击了发送后,设置button要过一段时间才能继续点击。下面是一个简单的例子:
复制代码 代码如下:

<html>
<head>
<title>点击获取验证码按钮后按钮变灰,倒计时一段时间后又可重复点击</title>
</head>
<body>
<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>
</body>
</html>
js检查页面上有无重复id的实现代码
基于pthread_create,readlink,getpid等函数的学习与总结
jcrop基本参数一览
jQuery .attr()和.removeAttr()方法操作元素属性示例
js 调用父窗口的具体实现代码
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved