<script type="text/javascript">
var clock = ‘‘;
var nums = 60;
var btn;
function sendCode(thisBtn) {
var telephone = $("#telephone").val();
var reg = /^1(3|5|7|8)[0-9]{9}$/;
var v = reg.test(telephone);
if(v){
$.post("../../customer_sendMsg.action",{"telephone":telephone});
btn = thisBtn;
btn.disabled = true; //将按钮置为不可点击
btn.value = nums + ‘秒后重新获取‘;
clock = setInterval(doLoop, 1000); //一秒执行一次
}
}
function doLoop() {
nums--;
if (nums > 0) {
btn.value = nums + ‘秒后重新获取‘;
} else {
clearInterval(clock); //清除js定时器
btn.disabled = false;
btn.value = ‘重新获取验证码‘;
nums = 60; //重置时间
}
}
</script>