首页 > 代码库 > 短信验证码

短信验证码

短信验证码,无注释,url顺便写的错的,所以会报错

 

技术分享
 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title>短信验证码 </title>    
 6     <script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
 7     <style>
 8         .sign_call span,input,p{
 9             float: left;
10         }
11     </style>
12     </head>
13         <body>
14     <div class="sign_call">
15         <span>验证码:</span>
16         <input type="text" placeholder="请输入短信验证码" />
17         <p onclick="">
18             <span id="btn" onclick="thetime(this.id)">获取验证码</span>
19         </p>
20     </div>
21     <script>
22         function thetime(p){
23             var wait = 60;  
24              document.getElementById(p).disabled = false;  
25               function time(o) {  
26                 if (wait == 0) {  
27                        o.removeAttribute("disabled");  
28                        o.innerHTML = "重新获取验证码";  
29                        wait = 60;  
30                        o.setAttribute("onclick","thetime(this.id)");
31                 } else {  
32                        o.setAttribute("disabled", true);  
33                        o.removeAttribute("onclick");
34                        o.innerHTML = wait + "秒后重新获取";  
35                        wait--;  
36                        setTimeout(function () {  
37                            time(o)  
38                        },1000)  
39                 }  
40             }
41             time(document.getElementById(p));
42             var mobile = document.getElementById(btn).value;
43 
44             $.ajax({
45                 type: "POST",
46                 url: "http://che.anet.cn/index.php/Ios/UserTest/ajaxtest",
47                 data: mobile=+mobile,
48                 dataType: json,
49                 success: function(msg){
50                       if(msg.status == 1){
51                            alert(msg.content); 
52                     }else{
53                         alert(msg.content);                  
54                     }
55                 } 
56             });
57 
58         }
59 
60     </script>
61 </body>
62 </html>
View Code

 

正在练习,可能有错误

短信验证码