Home > Web Front-end > JS Tutorial > js implements SMS verification code countdown function

js implements SMS verification code countdown function

小云云
Release: 2018-03-02 15:14:38
Original
2582 people have browsed it

This article mainly shares with you js to implement the SMS verification code countdown function. I hope it can help everyone.

js part

<script type="text/javascript">   
  var countdown=60;   
  function settime(obj) {   
      if (countdown == 0) {   
          obj.removeAttribute("disabled");      
          obj.value="免费获取验证码";   
          countdown = 60;   
          return;  
      } else {   
          obj.setAttribute("disabled", true);   
          obj.value="重新发送(" + countdown + ")";   
          countdown--;   
      }   
   setTimeout(function() { 
   settime(obj) }   
   ,1000);  
    
  }  
  function dd(){
   var obj = document.getElementById("test1");
   obj.innerHTML="";
   var nullOp = document.createElement("option");
   nullOp.setAttribute("value", "");
   nullOp.appendChild(document.createTextNode("请选择"));
   obj.appendChild(nullOp);
   for ( var int = 0; int < 1; int++) {
    var op = document.createElement("option");
    op.setAttribute("value", "123");
    op.appendChild(document.createTextNode("123"));
    obj.appendChild(op);
   }
  });
 </script>
html部分
<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> 
<input type="text" id="dd" onclick="dd()" value="sdf" />
Copy after login

Related recommendations:

How to use php to send SMS verification codes

JS implementation SMS verification code

JS implementation of sample code sharing for obtaining SMS verification code and countdown function when user registers

The above is the detailed content of js implements SMS verification code countdown function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template