I have the following form:
<form class="form-validation">
<input name="product[0][name]" id="form_product[0][name]" data-rule-required="true">
</form>
which is checked using the jQuery validation plugin. I call it this way:
$(".form-validation").validate();
Validation works as expected. Then I have a button that dynamically adds fields to the form, basically it creates this:
<form class="form-validation">
<input name="product[0][name]" id="form_product[0][name]" data-rule-required="true">
<input name="product[1][name]" id="form_product[1][name]" data-rule-required="true">
<input name="product[2][name]" id="form_product[2][name]" data-rule-required="true">
...
</form>
Now after that, validation no longer behaves normally. He is still validating the form, but I am getting strange results. Sometimes the onsubmit value from filed3 is moved to field2, and rules are also passed between fields.
I think I will need to tell the validator that new fields have been added, but I don’t know how?
source
share