我试图使用jquey.validation插件验证select2字段,但没有任何反应.
我想选择必填字段.
我使用这个自定义验证功能:
$.validator.addMethod("requiredcountry",function(value,element,arg){
return arg != value;
},"Value must not equal arg.");
这是规则:
rules:
{
country:
{
required: true,requiredcountry: ""
}
}
我应该使用什么select2字段来匹配规则?
我感谢任何想法如何使select2与jquery.validation一起工作
10倍
解决方法
只需添加ignore:[],在你的表单验证功能.它将启用隐藏的字段验证.因此,您将获得选择2的验证
$("#ContactForm").validate({
ignore: [],rules: {
//Rules
},messages: {
//messages
}
});