60秒重发验证码

<td>验证码:</td>
            <td><input type="text" id="verification" class="input-textone" name="verification"/></td>
            <td><input type="button" style="background:#00B2EE ;padding:10px 5px" id="sendVer" value="免费获取验证码"  onclick="sendVerification(this)" />  </td>



//发送验证码

var countdown=60;
function settime(val) {
    var cout = 1; //记录次数
    if (countdown == 0) {
        val.removeAttribute("disabled");    
        val.value="免费获取验证码";
        countdown = 60;
        cout = 0;
    } else {
        val.setAttribute("disabled", true);
        val.value="重新发送(" + countdown + ")";
        countdown--;
    }
    if(cout){
        setTimeout(function() {
            settime(val)
        },1000)
    }
}

猜你喜欢

转载自blog.csdn.net/u012325073/article/details/51983586