发送随机数手机验证码60秒倒计时

     mm.mobileCheck = function(t){
                var mobile = $("#user_mobile").val();
                if(""===$.trim(mobile)){
                        $.sscmpMsg().showWarnMessage("请输入手机号码!");
                        return;
                }
                $(t).attr('disabled', 'disabled');
                var chars = ['0','1','2','3','4','5','6','7','8','9'];
                var code = [];
                code.push(chars[parseInt(10*Math.random())]);
                code.push(chars[parseInt(10*Math.random())]);
                code.push(chars[parseInt(10*Math.random())]);
                code.push(chars[parseInt(10*Math.random())]);
                var codeStr = code.join('');

                mm.apiAjax({
                        url: path.u('/index/sms/registerCard'),
                        data: {
                                user_mobile: mobile,
                                code:codeStr
                        },
                        success: function (data) {
                        }
                 });
                $("#mobile_code").val(codeStr);
                var s = 60;
                var task = setInterval(function(){
                        if(s<1){
                                clearInterval(task);
                                $(t).removeAttr('disabled');
                                $(t).text("重新发送");
                                return;
                        }
                        s = s-1;
                        $(t).text(s.toString()+"秒");
                        }, 1000 );
        }        

 

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2021-12-18
  • 2021-12-28
  • 2021-11-18
  • 2021-11-18
  • 2021-12-22
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-06-29
  • 2021-11-03
  • 2022-12-23
  • 2021-12-18
相关资源
相似解决方案