1 <script type="text/javascript"> 2 var countdown=60; 3 function settime(val) { 4 var e = $('#email').val(); 5 //对电子邮件的验证 6 var myreg = /^([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|.]?)*[a-zA-Z0-9]+.[a-zA-Z]{2,3}$/; 7 if(!myreg.test(e)) 8 { 9 return; 10 } 11 if (countdown == 0) { 12 val.removeAttribute("disabled"); 13 val.value="获取验证码"; 14 countdown = 60; 15 return; 16 } else { 17 val.setAttribute("disabled", true); 18 val.value="重新发送(" + countdown + ")"; 19 countdown--; 20 } 21 setTimeout(function() { 22 settime(val) 23 },1000) 24 } 25 </script>