I am using the jQuery Validation plug-in for a rather large form (the s开发者_开发知识库ize of the form is large by client request and non-negotiable).
I have been able to implement all of the sometimes complex validation dependencies with relative ease. But now I am stuck at a relative simple validation that somehow doesn't seem to fit in the validations plug-in concept:
Atleast one of the over 30 form input fields has to be filled.
That's it.
The problems that I am facing:
1) Since we are talking about 30 fields I do not want to highlight all fields, only show the error ( errors are shown in a special area over the form).
2) An elegant solution would be preferred. Adding 30 " #input_id: required " rules is not elegant.
Is my only option to circumvent the validation plugin?
Thank you, Alexis
You could have a hidden field that gets written to based on any entry of data in the form then have the validator plugin check that it doesn't return an empty string on submit. You can also add a toggleClass to on onChange event of any of the fields.
Forgive me for answering a question with a question..
I think you could do this without a plugin quite easily, do you require validation on all input objects or just text inputs?
Is your validation simple (eg. required) or indepth (eg. email validation)?
精彩评论