jquery validate - how to validate hidden input value

jquery validate - how to validate hidden input value

Hi Team,

I have read a lot of posts about this and tried most without success.

The docs suggest the ignore directive defaults to ":hidden", but I have tried "", [] and various :not:hidden settings without success.

I have a complex form and as part of the form I have a section for uploading images. To keep track of this requirement I write the number of successful uploads to a hidden input as follows:

<input type="hidden" name="evidence_uc" id="evidence_uc" value="">

The upload is controlled with scripts and I can see the value changing accordingly eg "1", "2" etc

I have tried using "number" method, and also adding my own method ie

        $.validator.addMethod("uploadCount", function(value, element, params) {
                return this.optional(element) || parseInt(value) >= params[0];
        }, "Please upload at least one image." );

When I submit my form, all of the other fields display their messages correctly apart from my hidden input field! If I change the type of the input to text, it works fine.

Is the ignore option broken, or have I done something else wrong?

Further, if you have a neater way to offer some feedback to the user please let me know.

Thx, Paul
    • Topic Participants

    • paul