标签:name microsoft ble stat color soft end 号码 文本框
//html页面
手机号:<input type="text" name="tel" id="tel"><br>
验证码:<input type="text" name="code" id="code" size="8"><input type="button" id="btn" value="获取验证码" onclick="sendSMS()">
<br>
<input type="button" value="手机号登录" id="but">
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/js/sms.js"></script>
//js页面
var countdown=60;
function sendSMS(){
//判断手机号的文本框
var reg=/^1[35876]\d{9}$/;
var tel=$("#tel").val();
if(tel==""){
alert("手机号不能为空");return false;
}
if(!reg.test(tel)){
alert("手机号码不合法");return false;
}
//调用倒计时
var obj = $("#btn");
settime(obj);
$.get(
"http://localhost/Month8/day1/public/index.php/index/qlogin/dlogin_do?tel="+tel,
function (data) {
console.log(data);
})
}
function settime(obj) { //发送验证码倒计时
if (countdown == 0) {
obj.attr(‘disabled‘,false);
//obj.removeattr("disabled");
obj.val("免费获取验证码");
countdown = 60;
return;
} else {
obj.attr(‘disabled‘,true);
obj.val("重新发送(" + countdown + ")");
countdown--;
}
setTimeout(function() {
settime(obj) }
,1000)
}
标签:name microsoft ble stat color soft end 号码 文本框
原文地址:https://www.cnblogs.com/chaihtml/p/10128012.html