倒计时

来源:互联网 发布:淘宝成功案例 编辑:程序博客网 时间:2024/06/05 12:39

<li><input type="number" name="contactPhone" style="width: 160px;" maxlength="6"><input id="sendCheckCode" name="sendCheckCode" type="button" class="btn_yz cp " value="发送验证码"></li>

        /*获取验证码倒计时*/

        var wait=60;

        function time(o) {

            if (wait == 0) {

                o.removeAttribute("disabled");

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

                wait = 60;

                $(".btn_yz").css("background-color","#5bb75b");

                $(".btn_yz").css("color","#fff");

            } else {

                o.setAttribute("disabled", true);

                o.value=wait+"s后"+"重新发送";

                wait--;

                setTimeout(function() {

                    time(o)

                }, 1000)

                $(".btn_yz").css("background-color","#f1f1f1");

                $(".btn_yz").css("color","#666");

            }

        }

        $(".btn_yz").click(function(){

            var mobile = $("#expressive_phone").val();

            if(mobile == ""){

                alert('提现人手机号不能为空!');

            } else if (mobile !="") {

                if (/^((\d{3}-\d{8}|\d{4}-\d{7,8})|(1[3|5|7|8][0-9]{9}))$/.test(mobile)) {

                    time(this);

                    $.ajax({

                        url: "${ctx}/api/b2b2c/storeApi!sendCheckCode.do?ajax=yes",

                        type: "POST",

                        data: "mobile=" + mobile,

                        async: false,

                        dataType: "json",

                        success: function (json) {

                            alert(json.message);

                        }

                    });

                }else {

                    alert('提现人手机号输入有误请重新输入!');

                }

            }

        });

0 0
原创粉丝点击