[JavaScript] 给绑定手机发送手机验证码 点击之后 倒计时 一分钟之后 才能再次点击 →→→→→进入此内容的聊天室

来自 , 2019-05-04, 写在 JavaScript, 查看 107 次.
URL http://www.code666.cn/view/7f6caf1f
  1. *******************************************         JS          ***************************************************
  2. // 给绑定手机发送手机验证码
  3. function sendRand_oldMobile() {
  4.         $.ajax({
  5.                 type : "POST", // post提交方式,默认是get
  6.                 url : contextpath + "shopuser/myaccount/SendRand.do", // 请求的数据源
  7.                 data : { // 传递的数据
  8.                         mobile : $('#check_mobile').val() ,// 手机号
  9.                 },
  10.                 success : function(response) {
  11.                         var result = $.parseJSON(response);
  12.                         alert(result.msg);
  13.                         if(result.code=="0109" || result.code=="0110"){
  14.                                 var time = 60;
  15.                                 // var code = $(this);
  16.                                 $("#fsdmsg2").addClass("msgs1");
  17.                                 $("#fsdmsg2").removeAttr("onclick");
  18.                                 var t = setInterval(function() {
  19.                                                         time--;
  20.                                                         $("#fsdmsg2").val(time  + "秒后重新获取");
  21.                                                         if (time == 0) {
  22.                                                                 clearInterval(t);
  23.                                                                 $("#fsdmsg2").val("重新获取");
  24.                                                                 $("#fsdmsg2").removeClass("msgs1");
  25.                                                                 $("#fsdmsg2").attr("onclick","sendRand_oldMobile();");
  26.                                                         }
  27.                                                 }, 1000)
  28.                         }
  29.                 }
  30.         })
  31. }
  32.  
  33.  
  34.  
  35. *************************************************          Html    ***************************************************************
  36.  
  37.                                 <input type="button" id="fsdmsg2" value="获取手机验证码" onclick="sendRand_oldMobile()"
  38.                                         class="msgs">
  39.  
  40.  
  41. *********************************************************CSS ********************************************************
  42.  
  43.  .msgs1 {
  44.         background: #E6E6E6;
  45.         color: #818080;
  46.         border: 1px solid #CCCCCC;
  47. }
  48. .msgs {
  49.         -webkit-border-radius: .5em;
  50.         -moz-border-radius: .5em;
  51.         border-radius: .5em;
  52.         display: inline-block;
  53.         width: 200px;
  54.         color: #fff;
  55.         font-size: 14px;
  56.         border: 1px solid #0697DA;
  57.         text-align: center;
  58.         height: 30px;
  59.         line-height: 30px;
  60.         background: #0697DA;
  61.         cursor: pointer;
  62. }
  63.  

回复 "给绑定手机发送手机验证码 点击之后 倒计时 一分钟之后 才能再次点击"

这儿你可以回复上面这条便签

captcha