function validateLogin(act){
if(act == 'login'){
var messages =
{
code:{
required:"验证码不能为空", minlength:'验证码长度不符', maxlength:'验证码长度不符', number:'验证码只能是数字'
},
mobile:{
required:"手机号不能为空", mobile:"请输入正确的手机号"
}
},
rules = {
code:{
required:true, minlength:1, maxlength:8, number:true
},
mobile:{
required:true, mobile:true
}
};
}else{
var messages =
{
mobile:{
required:"手机号不能为空", mobile:"请输入正确的手机号"
}
},
rules = {
mobile:{
required:true, mobile:true
}
};
}
addValidator('mobile');
var validator = $("#login_form").validate({
errorPlacement:function(error, element) {
$.tips(error[0].innerText);
},
onkeyup:false,
rules:rules,
messages:messages,
});
if(!$("#login_form").valid()){
return false;
}
return true;
}
我先validateLogin('login')
再validateLogin('code')
结果一直提示验证码不能为空,意思就是validateLogin('login')
的时候记忆没有清除,什么resetForm,removeClass,removeAttr,removeData都试过了,没用!求解决办法