휴대폰 문자 발송 JS 인증

18047 단어 js
  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     }

좋은 웹페이지 즐겨찾기