• asp 时间倒数后按钮可用


      <asp:Button runat="server" ID="btn"  Text="免费获取验证码" onclick="btn_Click" />

    js:

    <script type="text/javascript">
           var wait = 6;
           function time() {
               if (wait == 0) {
                   document.getElementById("btn").removeAttribute("disabled");
                   document.getElementById("btn").value = "免费获取验证码";
                   wait = 6;
               } else {
                   document.getElementById("btn").setAttribute("disabled", true);
                   document.getElementById("btn").value = wait + "秒后可以重新发送";
                   wait--;
                   setTimeout(function () {
                       time()
                   },
                1000)
               }
           }
         
    </script>    

    后台页面加载时调用js

      protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                 ClientScript.RegisterStartupScript(GetType(), "js", "time()", true);
            }
        }

    效果图:

  • 相关阅读:
    k8s-istio记录
    k8s
    单词 -(动物)
    RxJs
    .netcore 3.1 unbuntu
    单词规整
    AutoMapper
    时间
    ye
    特殊权限
  • 原文地址:https://www.cnblogs.com/smile-wei/p/4120522.html
Copyright © 2020-2023  润新知