I use the "depend" in jQuery Validation plugin in order to apply some validation rules only in specific cases. This is the code I use to do it in case I want a field required
only under certain circumstances.
fieldA: {
required: {depends: function () {
return $('#FormName select[name="fieldB"]').val() === '10';
}}
}
In case I want to use the valueNotEquals
rule I have a syntax like this:
fieldA:
{valueNotEquals: "0"}
If I want to use "depends", what is the right syntax? These two attempts gave error and syntax error.
Attemp 1 (error for I could not indicate WHAT value it must not equals)
fieldA:
{valueNotEquals: {depends: function () {
return $('#QuestionarioForm select[name="lavoroMadre"]').val() === '10';}}
Attemp 2 (syntax error)
fieldA:
{valueNotEquals: "0" {depends: function () {
return $('#QuestionarioForm select[name="lavoroMadre"]').val() === '10';}}