js短信验证码

时间:2024-07-30 16:03:08

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

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>短信验证码 </title>
<script type="text/javascript" src="js/jquery-1.10.1.min.js"></script>
<style>
.sign_call span,input,p{
float: left;
}
</style>
</head>
<body>
<div class="sign_call">
<span>验证码:</span>
<input type="text" placeholder="请输入短信验证码" />
<p onclick="">
<span id="btn" onclick="thetime(this.id)">获取验证码</span>
</p>
</div>
<script>
function thetime(p){
var wait = 60;
document.getElementById(p).disabled = false;
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.innerHTML = "重新获取验证码";
wait = 60;
o.setAttribute("onclick","thetime(this.id)");
} else {
o.setAttribute("disabled", true);
o.removeAttribute("onclick");
o.innerHTML = wait + "秒后重新获取";
wait--;
setTimeout(function () {
time(o)
},1000)
}
}
time(document.getElementById(p));
var mobile = document.getElementById('btn').value; $.ajax({
type: "POST",
url: "http://che.anet.cn/index.php/Ios/UserTest/ajaxtest",
data: 'mobile='+mobile,
dataType: 'json',
success: function(msg){
if(msg.status == 1){
alert(msg.content);
}else{
alert(msg.content);
}
}
}); } </script>
</body>
</html>

正在练习,可能有错误