0712-2888027 189-8648-0214
微信公眾號(hào)

孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號(hào)

當(dāng)前位置:主頁(yè) > 技術(shù)支持 > Javascript/JQuery > JQuery源代碼:信息已發(fā)出,60秒后重新發(fā)送

JQuery源代碼:信息已發(fā)出,60秒后重新發(fā)送

時(shí)間:2024-09-20來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 847次
JQuery源代碼:信息已發(fā)出,60秒后重新發(fā)送

HTML源代碼片斷:

<!--短信驗(yàn)證碼-->
        <div class="vervode_main ovhide hide">
            <div class="vercode_l fl">
                <input type="number" style="border:1px solid #e1e1e1;" placeholder="短信驗(yàn)證碼" name="code" value="" regexp="^[0-9]{4,6}$">
                <div class="code_error hide">
                    <i class="iconfont icon-pc-tishi"></i>
                    <span>請(qǐng)輸入正確驗(yàn)證碼</span>
                </div>
            </div>
            <div class="vercode_r">
                <button type="button" class="" id="sendCode" onclick="getVerify1()">獲取驗(yàn)證碼</button>
                <div class="send_again hide"><span>60</span>s后重新發(fā)送</div>
            </div>
        </div>

JQuery源代碼片斷:
 
<script>
    var miao1 = 60;
    var m1 = null;
 
    var codeBtnObj1 = $("#sendCode");
    var daojishi1 = function() {
        clearInterval(m1);
 
        if (miao1 == 0) {
            codeBtnObj1.html('獲取驗(yàn)證碼');
            miao1 = 60;
            $("#sendCode").attr("onclick","getVerify1()");
        } else {
            miao1 = miao1 - 1;
            codeBtnObj1.html(miao1 + 's后重新發(fā)送');
            m1 = setInterval(daojishi1, 1000);
            $("#sendCode").attr("onclick","getalert()");
        }
    };
 
    function  getalert() {
        layer.alert('信息已發(fā)出,60秒后重新發(fā)送');
    }
 
    function getVerify1() {
        var tel = $.trim( $("input[name=tel]").val() );
        if(tel=='') {
            layer.alert('請(qǐng)輸入手機(jī)號(hào)');
            return;
        }
        $.ajax({
            url: "http://www.k431ba.cn/sendmsgcode",
            type: "POST",
            data: {phone: tel},
            dataType: "json",
            success: function (data) {
                if (data.status == 1) {
                    daojishi1();
                } else {
                    alert(data.msg);
                }
            }
        });
    }
 
    function guanbi() {
        $("#gray").hide();
        $(".login").hide();
    }
 
    function showlogin(){
        $("#gray").show();
        $(".login").show();
    }
</script>

手機(jī)號(hào)驗(yàn)證,動(dòng)態(tài)監(jiān)測(cè)手機(jī)號(hào)源代碼片斷:
<script>
    /*手機(jī)號(hào)輸入監(jiān)控*/
    function checkmobile(phone){
        var myreg = /^1[3-9][0-9]{9}$/;
        if(myreg.test(phone)){
            return true;
        }else{
            return false;
        }
    }

    //輸入手機(jī)號(hào)時(shí),動(dòng)態(tài)監(jiān)測(cè)手機(jī)號(hào)
    $("input[name=tel]").on("keyup",function(){
        if(checkmobile($(this).val())){
            var phone=$(this).val();
            $.ajax({
                url: "/index.php/Index/checktel",
                type: "POST",
                data: {phone: phone},
                dataType: "json",
                success: function (data) {
                    if(data.status!=1){
                        if($(".vervode_main").hasClass("hide")){
                            $(".vervode_main").removeClass("hide");
                        }
                    }
                }
            });
        }else{
            $(".vervode_main").addClass("hide");
        }
    })
</script>

熱門(mén)關(guān)鍵詞: JQuery 源代碼 信息已發(fā)出

您可能感興趣的相關(guān)文章:

欄目列表
推薦內(nèi)容
熱點(diǎn)內(nèi)容
展開(kāi)