我正在使用jQuery的验证插件: http://docs.jquery.com/Plugins/Validation。如何免除要验证的元素?
我想知道如何豁免一个字段进行验证?目前表单中的所有字段都会自动检查。
我不知道这是否会因为我想免除不包括(显然:))元素有助于
$("#contactForm").validate({
rules: {
first_name:{required: true,charsonly:true,minlength: 1 },
last_name:{required:true,charsonly:true,minlength: 1 },
birthday:{required:true,min:1,max:31 },
birthmonth:"required",
birthyear:"required",
username: {required: true,minlength:1,maxlength:32,username:true,notChinese:true,noSpecial:true},
password1:{required:true,minlength: 5,maxlength: 10, alphaNum: true },
password2:{required:true,minlength: 5,maxlength: 10, alphaNum: true, equalTo: "#password1"},
currency:"required",
address:{required: true,noSpecial:true,minlength:2},
city:{required: true,noSpecial:true,minlength:2},
state:{noSpecial:true},
countrycode:"required",
zip:{required:true,zipTest:true},
email:{required:true,email: true},
confirmemail:{required: true,equalTo: "#email",email:true},
phone:{required: true,minlength:6,maxlength:20,phoneUS:true},
cellphone:{required: true,minlength:6,maxlength:20,phoneUS:true},
custom06:{acceptIM:true}
} });
发现了它。 我使用了忽略验证方法。
这里的
$("#myform").validate({
ignore: ".ignore"
})
只是为了澄清任何信息领域。我想要做的就是删除这个插件,即使没有对该元素进行验证,该插件也会自动附加这段代码。 – wnoveno 2010-03-08 07:02:14
看来问题源于使用全局规则函数而不是设置每个元素的类。我仍然不知道如何解决这个问题。 – wnoveno 2010-03-08 07:55:00