jquery validation plugin - required = false NOT stopping validation of field

jquery validation plugin - required = false NOT stopping validation of field

Hi Team,

I have a complex form and mostly everything works as I intend (and understand). The final little problem occurs when I change the value of a pulldown menu and then expect the validation to behave differently for one field.

the rule:

            evidence_uc: {
                required: function(element) {
                        var ret = (catVal != 8 && catVal != 9);
console.log(ret);
                        return ret;
                    },
                min: 1
            },

and the messages:

            evidence_uc: {
                required: "Please upload at least one image",
                min: "Please upload a minimum of one image"
            },

The html:                    <input type="hidden" name="evidence_uc" id="evidence_uc" value="0">

I only ignore:         ignore: ".no-val",
 
So catVal is the value of the pulldown menu and I can see that correctly being set.
The console correctly shows true or false, but in either case I am still seeing the "min" validation message, which is driving me nuts!

I have a change event on the pulldown and when that fires I resetForm(). So I am baffled why this doesn't work as I expect? I expect if required is false that the evidence_uc will not be validated.

Have I got that wrong? Any suggestions welcomed please.

Thx Paul

    • Topic Participants

    • paul