JQuery源代碼:信息已發(fā)出,60秒后重新發(fā)送
HTML源代碼片斷:
HTML源代碼片斷:
<!--短信驗證碼-->
<div class="vervode_main ovhide hide">
<div class="vercode_l fl">
<input type="number" style="border:1px solid #e1e1e1;" placeholder="短信驗證碼" name="code" value="" regexp="^[0-9]{4,6}$">
<div class="code_error hide">
<i class="iconfont icon-pc-tishi"></i>
<span>請輸入正確驗證碼</span>
</div>
</div>
<div class="vercode_r">
<button type="button" class="" id="sendCode" onclick="getVerify1()">獲取驗證碼</button>
<div class="send_again hide"><span>60</span>s后重新發(fā)送</div>
</div>
</div>
JQuery源代碼片斷:
JQuery源代碼片斷:
<script>
var miao1 = 60;
var m1 = null;
var codeBtnObj1 = $("#sendCode");
var daojishi1 = function() {
clearInterval(m1);
if (miao1 == 0) {
codeBtnObj1.html('獲取驗證碼');
miao1 = 60;
$("#sendCode").attr("onclick","getVerify1()");
} else {
miao1 = miao1 - 1;
codeBtnObj1.html(miao1 + 's后重新發(fā)送');
m1 = setInterval(daojishi1, 1000);
$("#sendCode").attr("onclick","getalert()");
}
};
function getalert() {
layer.alert('信息已發(fā)出,60秒后重新發(fā)送');
}
function getVerify1() {
var tel = $.trim( $("input[name=tel]").val() );
if(tel=='') {
layer.alert('請輸入手機號');
return;
}
$.ajax({
url: "http://m.9b66.com.cn/sendmsgcode",
type: "POST",
data: {phone: tel},
dataType: "json",
success: function (data) {
if (data.status == 1) {
daojishi1();
} else {
alert(data.msg);
}
}
});
}
function guanbi() {
$("#gray").hide();
$(".login").hide();
}
function showlogin(){
$("#gray").show();
$(".login").show();
}
</script>
手機號驗證,動態(tài)監(jiān)測手機號源代碼片斷:
手機號驗證,動態(tài)監(jiān)測手機號源代碼片斷:
<script> /*手機號輸入監(jiān)控*/ function checkmobile(phone){ var myreg = /^1[3-9][0-9]{9}$/; if(myreg.test(phone)){ return true; }else{ return false; } } //輸入手機號時,動態(tài)監(jiān)測手機號 $("input[name=tel]").on("keyup",function(){ if(checkmobile($(this).val())){ var phone=$(this).val(); $.ajax({ url: "/index.php/Index/checktel", type: "POST", data: {phone: phone}, dataType: "json", success: function (data) { if(data.status!=1){ if($(".vervode_main").hasClass("hide")){ $(".vervode_main").removeClass("hide"); } } } }); }else{ $(".vervode_main").addClass("hide"); } }) </script>