我正在使用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