当我尝试验证下拉菜单时,我无法使用验证插件。在 chrome 中,我收到一条警告消息,上面写着:“没有选择,无法验证,什么都不返回”
$('#wpuf_form').validate({
debug: true,
rules: {
"category[]" : {
required:{
depends: function(element){
return $('.cat').val() == '-1';
}
}
}
},
submitHandler: function(form){
alert('test');
}
});
<!-- this the html -->
<form id="wpuf_form" name="wpuf_form" action="" method="POST">
<select name="category[]" id="cat" class="cat">
<option value="-1">– Select –</option>
<option class="level-0" value="1">test</option>
<option class="level-0" value="2">test2</option>
<option class="level-0" value="3">test3</option>
</select>
<input type="submit" name="wpuf_new_post_submit" value="Submit Creation">
</form>
任何帮助将不胜感激。提前致谢!