当前位置 : 主页 > 编程语言 > java >

获取验证码

来源:互联网 收集:自由互联 发布时间:2022-06-23
验证码倒计时函数 var wait = 60; function time(o) { if(wait == 0) { o.removeAttribute("disabled"); o.value = "获取验证码"; wait = 60; } else { o.setAttribute("disabled", true); o.value = "重新发送(" + wait + ")"; o.style.bac

 

验证码倒计时函数

    var wait = 60;

                            function time(o) {

                                   if(wait == 0) {

                                          o.removeAttribute("disabled");

                                          o.value = "获取验证码";

                                          wait = 60;

                                   } else {

                                          o.setAttribute("disabled", true);

                                          o.value = "重新发送(" + wait + ")";

                                          o.style.backgroundColor = '';

                                          wait--;

                                          setTimeout(function() {

                                                        time(o)

                                                 },

                                                 1000)

                                   }

                            }

       $("#btn").click(function(){

                     phone1 = $("#phone1").val();

                     if(checkPhone(phone1)){

                            time(this);

                            $.ajax({

                                   url: "http://ezist.cn/api/verificationCodes",

                             type: 'post',

                             dataType: "json",

                             data: {tel:phone1,verify:'true'},

                             success: function(data) {

                                          mui.toast("验证码已发送,请注意查收。");

                                          mes = data.verification_key;

                             },

                             error: function (data) {

                                 mui.toast("验证码请求失败");

                             }

                            });

                     }

              })


上一篇:倒计时
下一篇:没有了
网友评论