Send SMS countdown (with data verification)##Dry goods

/* Get verification code */ 
     $( "#sendcode").click( function () {
 //          alert(1) 
    var number = $('#tel' ).val();
     var data = {
       'mobile' : number,
       'aim': 1
    };
    if (data.mobile == "" || data.mobile.length != 11 ) {
       //         alert("Please enter your phone number") 

    } else {
 //     console.log(data); 
      $.ajax({
        type: "post",
        url: "interface" ,
        async: true,
        dataType: 'json',
        contentType: "application/json",
        data: JSON.stringify(data),
        success: function(data) {
          console.log(data);

          // Countdown     
          var o = $("#sendcode" );
           if (data.result.statusCode == 2999 ) {
            locktime (o);
          } else
          if(data.result.statusCode == 0) {
            team(o);
          } else {
            $( "#error").html("The phone number has been registered" );
          }
     

        }

      });
    }
  })
  var wait = 60;

  function time(o) {
    if(wait == 0) {
      o.removeAttr("disabled");
      o.val( "Send SMS Verification" );
      wait = 60;
    } else {
      o.attr("disabled", true);
      o.val( "Resend(" + wait + ")" );
      wait--;
      setTimeout(function() {
          team
        },
        1000)
   }
  }
  
   var locks = 5;

  function locktime(o) {
    if(locks == 0) {
      o.removeAttr("disabled");
      o.val( "Send SMS Verification" );
      locks = 5;
    } else {
      o.attr("disabled", true);
      o.val( "Account is locked(" + locks + ")" );
      locks--;
      setTimeout(function() {
          locktime (o)
        },
        1000)
    }
  }

page structure

<div class="main-content" style="">
      <div class="warp">

        <div class="regist">
          <h2>注册</h2>
          <form id="registForm">
            <div class="form-cont">
              <input class="isMobilePhone" id="mobile" name="mobile" type="tel" placeholder="请输入手机号" required/>
            </div>
            <div id="errorMassage" class="error-massage"></div>
            <div class="form-cont clearfix">
              <input class="vCode" name="vCode" type="text" placeholder="请输入验证码" required/><input id="getVcode" class="btn" type="button" value="获取验证码" />
            </div>
            <div class="form-cont">
              <input id="password" name="password" = "set password"placeholder= "password"type required/>
            </div>
            <!--密码复杂度-->
            <div class="check-password">
              <span>简单</span><span>一般</span><span>复杂</span>
            </div>
            <div class="form-cont">
              <input name="lastPassword" type="password"/>required= "Confirm Password"placeholder
            </div>
            <div class="form-cont">
              <label id="agreement" class="selected-bg" for="che"><input id="che" class="che" type="checkbox" checked="checked" /></label><span>我已阅读并接受 <a id="protocol" href="">《隐私与服务协议》</a></span>
            </div>
            <div>
              <input id="sunminBtn" class="register-btn" type="button" value="立即注册" />
            </div>
          </form>
        </div>

        <div class="imgdown">
          <img src="img/iconbar.png" />
        </div>
      </div>
    </div>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324635688&siteId=291194637