手機傳送簡訊JS驗證

來源:互聯網
上載者:User

標籤:style   blog   http   ar   io   color   os   sp   on   

  1     function tj() {  2         var phone = jQuery(‘#phone‘).val();  3         var code = jQuery(‘#verificationcode‘).val();  4         var password = jQuery(‘#password‘).val();  5         var rpassword = jQuery(‘#rpassword‘).val();  6         var type = "開戶";  7         if (phone.length == 0 || phone == ‘請輸入您的手機號碼‘) {  8             alert("您的手機號碼不可為空!");  9             jQuery(‘#phone‘).focus(); 10             return false; 11         } 12         if (phone.length > 0) { 13             var ab = /^(13[0-9]|15[0-9]|18[0-9])\d{8}$/; 14             if (ab.test(phone) == false) { 15                 alert("您的手機號碼不正確!"); 16                 jQuery(‘#phone‘).focus(); 17                 return false; 18             } 19         } 20         if (code.length == 0 || code == ‘請輸入手機驗證碼‘) { 21             alert("您的手機驗證碼不可為空!"); 22             jQuery(‘#verificationcode‘).focus(); 23             return false; 24         } 25         if (password.length == 0 || password == ‘請輸入6-12位密碼‘) { 26             alert("您的密碼不可為空!"); 27             jQuery(‘#password‘).focus(); 28             return false; 29         } 30         if (password.length < 6 || password.length > 12) { 31             alert("密碼為6-12位!"); 32             jQuery(‘#password‘).focus(); 33             return false; 34         } 35         if (rpassword.length == 0 || rpassword == ‘請重新輸入密碼‘) { 36             alert("重複密碼不可為空!"); 37             jQuery(‘#rpassword‘).focus(); 38             return false; 39         } 40         if (rpassword != password) { 41             alert("兩次輸入密碼不一致!"); 42             jQuery(‘#rpassword‘).focus(); 43             return false; 44         } 45  46         jQuery.ajax({ 47             type: "post", 48             url: "/KZH/Addkzhdata", 49             data: "phone=" + phone + "&code=" + code + "&password=" + password + "&type=" + type + "&t=" + new Date().toString(), 50             success: function (result) { 51                 if (result == "0") { 52                     alert("您的手機驗證碼不正確!"); 53                     jQuery(‘#verificationcode‘).focus(); 54                     return false; 55                 } 56                 else if (result == "1") { 57                     jQuery(‘#phone‘).val(""); 58                     jQuery(‘#verificationcode‘).val(""); 59                     jQuery(‘#password‘).val(""); 60                     jQuery(‘#rpassword‘).val(""); 61                     alert("您的資料已提交,客服人員會儘快與您聯絡"); 62                     window.location.href = "http://www.jfinfo.com"; 63                 }  64                 else if (result=="yes") { 65                     $("#tc").show(); 66                 } 67  68             }, 69             error: function (result) { 70                 alert("訪問出錯!"); 71             } 72         }); 73     } 74  75     $(function(){ 76         $("#tc a.close").click(function(){ 77              $("#tc").hide(); 78         }) 79     }) 80  81     document.onkeydown = function (event) { 82         var e = event || window.event || arguments.callee.caller.arguments[0]; 83         if (e && e.keyCode == 13) { // enter 鍵 84             tj(); 85         } 86     }; 87  88     function getcode() { 89         var phone = jQuery(‘#phone‘).val(); 90         if (phone.length == 0 || phone == ‘請輸入您的手機號碼‘) { 91             alert("您的手機號碼不可為空!"); 92             jQuery(‘#phone‘).focus(); 93             return false; 94         } 95         if (phone.length > 0) { 96             var ab = /^(13[0-9]|15[0-9]|18[0-9])\d{8}$/; 97             if (ab.test(phone) == false) { 98                 alert("您的手機號碼不正確!"); 99                 jQuery(‘#phone‘).focus();100                 return false;101             }102         }103 104         jQuery.ajax({105             type: "post",106             url: "/KZH/Getcode",107             data: "phone=" + phone + "&t=" + new Date().toString(),108             success: function (rval) {109                 if (rval == "0") {110                     alert("您的資料已經提交過,客服人員會儘快與您聯絡!");111                 } else if (rval == "1") {112                     alert("資訊已發送,請查收!");113                     var count = 60; 114                     var countdown = setInterval(CountDown, 1000); 115                     var timeShow = $(".hQBtn")116                     function CountDown() { 117                                    timeShow.removeAttr("disabled");118                                    //timeShow.val(count + " 秒後重新發送");  119                                    timeShow.addClass("btn_hui").val(count + " 秒後重新擷取").attr("disabled","true");120                                     if (count == 0) { 121                                         timeShow.removeClass("btn_hui").val("擷取驗證碼").removeAttr("disabled");122                                         clearInterval(countdown); 123                                     }124                                       count--; 125                               }126                     }127             },128             error: function (result) {129                 alert("訪問出錯!");130             }131         });132     }

 

手機傳送簡訊JS驗證

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.