$("#nextSubmit").click(function(){
$("#recovePasswordForm").submit();
});
$("#upCaptcha").click(function(){
changeImg();
});
$("#recovePasswordForm").validate({
submitHandler:function(form){
$.ajax({
type: "GET",
data:{"phone":$("#mobilePhone").val(),"verifyCode":$("#verifyCode").val(),"recovePassword":"1"},
dataType: 'json',
url: $("#phoneExistFlag").val(),
success: function(response){
var data = response[0];
if(data.isPhoneExist){
$('[name="sessionKey"]').val(data.sessionKey);
form.submit();
}else{
if(data.passMessageFlag != ""){
if(data.passMessageFlag.indexOf("验证码")>=0){
$("#message2").html(data.passMessageFlag).attr("class","error");
$("#verifyCode").val("");
changeImg();
}else{
$("#message1").html(data.passMessageFlag).attr("class","error");
}
}
}
},
error:function(response){
$.msg.alert("The system is busy, sorry for the inconvenience!");
}
});
},
rules:{
mobilePhone:{required:true,minlength: 11,cRegex: true},
verifyCode:{required:true,minlength:3}
},
messages:{
mobilePhone:{required:"Please enter the mobile phone number!",minlength:"The mobile phone number is incomplete, please check!"},
verifyCode:{required:"Please enter the verification code!",minlength:"The verification code is entered incorrectly, please re-enter it!"}
},errorElement: "span", //Other tags can be used, remember to modify the style accordingly
errorClass : "error_error",
success:function(label) {
//label points to the above error message label em
label.removeClass().addClass("success"); //Add a custom success class
label.html("");//Clear the error message
}
});
$.validator.addMethod("cRegex", function (value,element) {
var isRegex = commValiCellphone(value);
return this.optional(element) || isRegex;
} , 'Please fill in the phone number correctly!');
from form validation plugin validate instance
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325206529&siteId=291194637
Recommended
Ranking