计时获取验证码

来源:互联网 发布:cs6色环插件mac 编辑:程序博客网 时间:2024/05/29 15:45
var wait=60;
function getCode(){
var codeBtn = document.getElementById("codeBtn");
codeBtn.style.border="none";
codeBtn.style.fontSize="12px";
codeBtn.style.color="#9C9C9C";
codeBtn.value=wait+"秒后重新获取";
time(codeBtn);
$.ajax({
url:'${ctx}/statics!phoneMessage.json',
type:'POST',
data:{toolMessage:document.getElementById("phone").value},
async:false,
success:function(result){
code=result;
}
});
}
function time(o) {
if (wait == 0) {
o.value="获取验证码";
o.style.border="1px";
o.style.fontSize="14px";
o.style.color="black";
wait = 60;
} else {
o.value= wait + "秒后重新获取";
wait--;
setTimeout(
function() {
time(o)
},1000)
}
}
0 0
原创粉丝点击