Hi guys!
I am working on a quite big CMS project and we want to use jquery.validate.js as our validation-framework.
I am using data-attributes to apply rules to my elements and I have a complete customised handling of the validate-Method. Everything works like a charm.
The only problem I have is if I want to apply dynamic rules, I run into some problems:
Let's say I have two text-inputs and a checkbox. Initially the first text-input is mandatory, if the checkbox is clicked the first text-input should not be mandatory anymore, instead the second text-input becomes mandatory.
The validation of this form is initialized by a default-initialiser - rules are applied by the data-attributes like so:
<input type="text" data-rule-required="true" name="text1" />
<input type="text" name="text2" />
<input type="checkbox" name="checkbox" />
I am able to add rules to the elements, but I can't get rid of the default-rules, provided by the data-attributes (just like the documentation says, I know).
Still, I want to use this in a super dynamic way, at best handling all the functionality through data-attributes. I already have a complete implementation for this - the only thing that does not work is removing the "static" rules.
Does anyone have any idea how I can do that? Obviously I don't want to change the jquery.validate implemention itself! ;)
Thanks in advance!
Daniel