jQuery.validator.addMethod("valueNotEquals", function(value, element, params) { return this.optional(element) || (value != params[0]);}, "Please specify a value that is not equal to {0}");并声明规则:fieldA: { valueNotEquals: [0]} 自定义方法的演示: http://jsfiddle.net/cF3p5/ 现在您无需使用depends.只需编辑此自定义函数,使其表现出所需的效果即可.也许更像这样... Now you wouldn't need to use depends. Simply edit this custom function so that it behaves as you want. Maybe something more like this...jQuery.validator.addMethod("valueNotEquals", function(value, element, params) { if ($('#QuestionarioForm select[name="lavoroMadre"]').val() === params[1]) { return (value != params[0]); } else { return true; }}, "Please specify a value that is not equal to {0}");并声明规则:fieldA: { valueNotEquals: [0, 10]} 这篇关于如何添加“依赖项" jQuery Validation插件中的valueNotEquals规则的条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-25 08:12