驗證碼倒計時
<input type="button" id="btn" value="免費獲取驗證碼" />
<script type="text/javascript">
var wait = 30;
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value = "免費獲取驗證碼";
wait = 30;
} else {
o.setAttribute("disabled", true);
o.value = "重新發送(" + wait + ")";
wait--;
setTimeout(function() {
time(o)
}, 1000)
}
}
//document.getElementById("btn").οnclick=function(){time(this);}
$("#btn").on('click', function() {
var mobile = $("#mobile").val();
if (mobile == null || mobile == '') {
alert("驗證碼不能爲空")
} else {
time(this);
}
})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.