JS发送验证码读秒(转)

 1  <input type="button" id="btnR" value="发送验证码" class="send-a" style="border:0px;" />
 2                                                         <script type="text/javascript">
 3                                                             var wait = 60;
 4                                                             document.getElementById("btnR").disabled = false;
 5                                                             function time(o) {
 6                                                                 if (wait == 0) {
 7                                                                     o.removeAttribute("disabled");
 8                                                                     //$(o).attr("disabled", false);  jquery  
 9                                                                     o.value = "发送验证码";
10 
11                                                                     wait = 60;
12                                                                 } else {
13                                                                     o.setAttribute("disabled", true);
14                                                                     o.value = wait + "秒后,重新获取";
15                                                                     wait--;
16                                                                     setTimeout(function () {
17                                                                         time(o)
18                                                                     },
19                                                                      1000)
20                                                                 }
21                                                             }
22                                                             document.getElementById("btnR").onclick =
23                                                           function () {
24                                                               if ($('#txtRPhone').val().length > 0) {
25                                                                   sendSMS(2);
26                                                                   if (resV == 1) {
27                                                                       time(this);
28                                                                   }
29                                                               } else {
30                                                                   alert("请填写手机号");
31                                                               }
32                                                           }  
33                                                         </script>

 

posted @ 2015-03-17 11:42  满毅  阅读(1549)  评论(0)    收藏  举报