<div class="input-group-addon"><a style="width: 100%;height: 100%" href="javascript:xiaoyueLogin();" id="verbtn" >獲取驗證碼</a></div>
<script>
var InterValObj; //timer變量,控制時間
var count = 60; //間隔函數,1秒執行
var curCount; //當前剩餘秒數
$(function () {
$("#verbtn").click(function () {})
$("#lkchage").click(function () {
var mobile=$("#nickname").val();
var ver = $("#reg_verify").val();
if(ver==""){
alert("驗證碼不能爲空");
return;
}
$.post("/ucenter/member/foundpassword",{mobile:mobile,reg_verify:ver},function (data) {
console.log(data);
alert(data.msg);
location.href="/ucenter/member/login.html";
})
})
})
function xiaoyueLogin() {
var mobile=$("#nickname").val();
var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
if(!mobile){
alert('手機號不能爲空');
return false;
}
if (!reg.test(mobile)) {
alert('手機號碼格式不正確');
return false;
}
curCount = count;
$("#verbtn").removeAttr("href");
$("#verbtn").html("驗證碼(" + curCount + ")");
InterValObj = window.setInterval(SetRemainTime, 1000); //啓動計時器,1秒執行一次
$.get("/Mob/Message/sendsms?action=1&mobile="+mobile,function (data) {
alert(data.msg);
console.log(data.code);
if(data.code == 1){}
})
}
function SetRemainTime() {
if (curCount == 0) {
window.clearInterval(InterValObj); //中止計時器
$("#verbtn").attr("href", "javascript:xiaoyueLogin();");
$("#verbtn").html("從新發送驗證碼");
}
else {
curCount--;
$("#verbtn").html("驗證碼(" + curCount + ")");
}
}
</script>