短信验证码
Posted 王多静
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了短信验证码相关的知识,希望对你有一定的参考价值。
短信验证码,无注释,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>
正在练习,可能有错误
以上是关于短信验证码的主要内容,如果未能解决你的问题,请参考以下文章