记录手机验证60秒倒计时js

[code lang=”js”]
function send_mobyzm(thiss){
var mobnum = $("#mob").val();
if(!mobnum || mobnum.length!=11){
alert(‘请输入正确的手机号’);
return false;
}
$.post("__APP__/member/common/sendphone1",{cellphone:mobnum,"bandlogin":1},function(data){
if(data.status==2){
alert(data.info);
}else if(data.status==1){//发送成功调用倒计时
settime(thiss);
};
},’json’);
}

var countdown=60;
function settime(val) {
if (countdown == 0) {
val.removeAttribute("disabled");
val.value="免费获取验证码";
countdown=60;
return false;
} else {
val.setAttribute("disabled", true);
val.value="重新发送(" + countdown + ")";
countdown–;
}
setTimeout(function() {
settime(val)
},1000)
}

[/code]

html代码:

[code lang=”html”]
<input type="text" id="mob" style="width:150px" /> <span>&nbsp;&nbsp;<input type="button" style="width:88px" value="获取验证码" onclick="send_mobyzm(this);" >
&nbsp;</span>
[/code]