其他分享
首页 > 其他分享> > 发送验证码

发送验证码

作者:互联网

$("#getCode").on("click", getCodeClick);
function getCodeClick() {
 if(!validatePhone('phone',$('#txtMobile')) || $('#txtMobile').attr('phone') != 'true'){
    return false;
 }  $("#ErrMessage").html("");  $("#getCode").off("click");  try {     new common.ajaxRequest({       url: url+"cmbntUser/getChangePhoneAuthCode?mobilePhone="+ $("#txtMobile").val().trim(),       type: "POST",       param: '',       dataType: "json",       header: header,       callBack: function (result) {         if(result.type =="SUCCESS"){           var lefttime = 60;           $("#getCode").attr("disabled", "disabled");           $("#getCode").html("60秒后重新获取");           var countDown = setInterval(function () {             lefttime--;             $("#getCode").html(lefttime + "秒后重新获取");              if (0 == lefttime) {                $("#getCode").html("重新获取");                $("#getCode").removeAttr("disabled");               $("#getCode").on("click", getCodeClick);               clearInterval(countDown);              }           }, 1000);          }else{            $("#ErrMessage").html(result.message);            $("#ErrMessage").attr("class", "tip textred");            $("#getCode").on("click", getCodeClick); }       }    });  } catch (ex) {   $("#ErrMessage").html("发送短信失败,请稍后再试。");     $("#ErrMessage").attr("class", "tip textred"); } return false;
}

 

标签:ErrMessage,lefttime,getCode,attr,验证码,发送,html,click
来源: https://www.cnblogs.com/myyouzi/p/11162000.html