1 <script src="/js/jquery-2.1.4.min.js"></script>
2 <script src="/js/jweixin-1.0.0.js"></script>
3 <script src="/js/exif.js"></script>
4 <script>
5 $(function () {
6 $("#btn_getcode").click(function () {
7 var disabled = $("btn_getcode").attr("disabled");
8 if (disabled) {
9 return false;
10 }
11 if ($("#txt_phone").val() == "" || isNaN($("#txt_phone").val()) || $("#txt_phone").val().length != 11) {
12 alert("请填写正确的手机号!");
13 return false;
14 }
15 $.ajax({
16 type: "POST",
17 url: "checkCode.ashx",
18 data: { mobile: $("#txt_phone").val(), name: $("#txt_name").val() },
19 dataType: "json",
20 async: false,
21 success: function (data) {
22 console.log('data:');
23 console.log(data);
24
25 if (data.status == "y") {
26 alert(data.info);
27 settime();
28 }
29 else {
30 alert(data.info);
31 }
32 },
33 error: function (err) {
34 console.log(err);
35 }
36 });
37 });
38 var countdown = 60;
39 //var _generate_code = $("#btn_getcode");
40 function settime() {
41 if (countdown == 0) {
42 $("#btn_getcode").attr("disabled", false);
43 $("#btn_getcode").val("获取验证码");
44 countdown = 60;
45 return false;
46 } else {
47 $("#btn_getcode").attr("disabled", true);
48 $("#btn_getcode").val("重新获取(" + countdown + ")");
49 countdown--;
50 }
51 setTimeout(function () {
52 settime();
53 }, 1000);
54 }
55 })
56 </script>
1 <body>
2 <form id="form1" runat="server">
3
4 <div class="a_inpList">
5 <div class="a_inpTitle">
6 <span class="a_essential">*</span>联系方式
7 </div>
8 <input type="number" name="phone" id="txt_phone" placeholder="请输入手机号" class="a_inp" runat="server" />
9 </div>
10 <div class="a_inpList1">
11 <div class="a_inpTitle1">
12 <span class="a_essential">*</span>验证码
13 </div>
14 <input type="text" name="txt_checkcode" id="checkcode" placeholder="请输入短信验证码" class="a_inpcode" runat="server" required="required" maxlength="6" />
15 <asp:Button CssClass="btn_getcode" ID="btn_getcode" runat="server" Text="获取验证码" />
16 </div>
17 </form>
18 </body>
1 <script>
2 function check() {
3
4 var tel = $("#txt_phone").val();
5 if (tel == "") {
6 layer.open({
7 content: "手机号不能为空",
8 style: 'background-color:#09C1FF; color:#fff; border:none;',
9 time: 2
10 });
11 return false;
12 }
13 else if (tel.length != 11) {
14 layer.open({
15 content: "手机号位数错误",
16 style: 'background-color:#09C1FF; color:#fff; border:none;',
17 time: 2
18 });
19 return false;
20 }
21 else if (isNaN(tel)) {
22 layer.open({
23 content: "手机号格式错误",
24 style: 'background-color:#09C1FF; color:#fff; border:none;',
25 time: 2
26 });
27 return false;
28 }
29 }
30 </script>
![]()