標籤:get 倒數 輸入 var nbsp 控制 res 錯誤 settime
}else {
alert("驗證碼已發送,請注意查收");
time();//調用驗證碼倒計時
document.getElementById(‘iputCode‘).setAttribute(‘class‘,result);//讓該元素添加calss
}
/**
* 點擊擷取驗證碼後顯示倒數時間
*/
var wait = 60;// 定義簡訊發送倒計時時間
function time(){
ocument.getElementById(‘obtain‘).disabled = false; //讓按鈕可以點擊
if(wait == 0) {
document.getElementById(‘obtain‘).removeAttribute("disabled"); //控制按鈕可點擊
document.getElementById(‘obtain‘).value = "擷取驗證碼";
document.getElementById(‘obtain‘).style.color = ‘#2C8FFF‘;
wait = 60; //還原倒計時
}else{
document.getElementById(‘obtain‘).setAttribute("disabled", true);//控制按鈕不可點擊
document.getElementById(‘obtain‘).value = "重新發送(" + wait + ")";
document.getElementById(‘obtain‘).style.color = ‘#C0BBBB‘;
wait--;
setTimeout(‘time()‘, 1000) //迴圈調用
}
}
/**
* 驗證驗證碼是否正確
*/
function verify() {
var yzm = document.getElementById(‘iputCode‘).value; // 擷取註冊使用者填寫的驗證碼
var yzmtwo = document.getElementById(‘iputCode‘).className; // 系統發送的驗證碼
if (yzm == ""){
alert("驗證碼不可為空");
return false;
}else if (yzm != yzmtwo){
alert("驗證碼錯誤,請重新輸入!");
eturn false;
}
return true;
}
//點擊下一步驗證驗證碼是否正確
$(function(){
//下一步
$(‘#nextStep‘).click(function(){
var ipone = isIpone($(‘#loginPhone‘).val());//手機號驗證
var loginPhone = document.getElementById(‘loginPhone‘).value;// 擷取使用者手機號碼
if(ipone != true){
return;
}
var yzm = verify();//此處調用驗證方法
if(yzm != true){
return;
}
if(ipone == true && yzm == true) {
// 下一步跳轉設定密碼頁面
window.open(‘resetPassword.html?iphone=‘+loginPhone)
}
})
})
手機號擷取驗證碼、驗證驗證碼是否正確