gistfile1.txt // 手机倒计时验证码$(function(){var flag = true; $("#btn").click(function(){ if($('#phone').val() == null || $('#phone').val() =="" || isPhoneNo($.trim($('#phone').val())) == false){ $("#tipPhone").html("手机号不能为
// 手机倒计时验证码 $(function(){ var flag = true; $("#btn").click(function(){ if($('#phone').val() == null || $('#phone').val() =="" || isPhoneNo($.trim($('#phone').val())) == false){ $("#tipPhone").html("手机号不能为空!"); }else{ $("#tipPhone").html(""); var codename = $(".codename").val(); $.ajax({ type: 'POST', url: 'my.php?mid=10&action=post_code', dataType: 'json', data:{mobile:codename}, success: function(data){ console.log(data); }, error: function(){ console.log("error"); } }); timerInt(); } }) }); function timerInt(){ var index = 60; $("#btn").val("重新发送(" + index + ")"); var timer = setInterval(function(){ index--; if(index < 0){ index = 0; clearInterval(timer); $("#btn").val("获取").removeAttr("disabled"); return; } $("#btn").val("重新发送(" + index + ")").attr("disabled","disabled"); },1000); }