I’m using jQuery validation plugin to validate a form. when one thing is selected in a selectbox a new selectbox is added trough ajax. this new element has class required but when I try to submit, it is not validated.
I know this is because when the validation plugin is initialized on the form the classes are checked to see which validations will be necessary. When a new item is added it is not checked for any classes, or initialized at all for that matter.
Is there a way to add the selectbox to the validation after it is initialized, maybe reinit the validation making it use its previous settings but rechecking its elements?
Found the solution with a fresh look, i found out that my selectboxes all had the name of
undefinedbecause of a mis-capitalized varname. This means only the first selectbox got validated.$field.rules('add', {required: true });was not necessary because the class required did take this time.