javascript - jquery.validate.js验证记忆无法清除
阿神
阿神 2017-04-11 13:16:56
0
1
693
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都试过了,没用!求解决办法

阿神
阿神

闭关修行中......

reply all(1)
迷茫

解决了,是验证规则的问题,参考
http://stackoverflow.com/ques...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template