zoukankan      html  css  js  c++  java
  • 实现发送短信验证码后60秒倒计时

    实现发送短信验证码后60秒倒计时

    https://www.oschina.net/code/snippet_2001568_48247

     var countdown = 0;
            function settime(obj) {
                if (countdown == 0) {
                    obj.removeAttribute("disabled");
                    obj.text = "免费获取验证码";
                    //countdown = 60;
                    return;
                } else {
                    obj.setAttribute("disabled", true);
                    obj.text = "重新发送(" + countdown + ")";
                    countdown--;
                }
                setTimeout(function () {
                        settime(obj);
                    },
                    1000);
            }
    
            $("#getcode").click(function () {
                if (CheckInput() == false) {
                    return;
                }
                if (countdown == 0) {
                    countdown = 60;
                    settime(this);
                } else {
                    return;
                }
                    
                _ajax("@Url.Action("GetVerificationCode","User")", {
                    e_mobile: $("#e_mobile").val()
                }, function (json) {
                    alert(json.msg);
                    if (json.flag > 0) {
                        cacheKey = json.cacheKey;
                        console.log(cacheKey);
                    }
                })
    
            });
  • 相关阅读:
    计算机基础
    程序的控制结构
    day 04作业
    数据类型-数据类型
    第二次作业
    第二次博客
    第一篇博客
    原生js与ajax应用
    ajax原理及其优缺点
    jQuery动画
  • 原文地址:https://www.cnblogs.com/shiningrise/p/6513221.html
Copyright © 2011-2022 走看看