victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

data-validation-optional-if-answered does not handle case of duplicate input name in another form. #651

Open WingGithub opened 6 years ago

WingGithub commented 6 years ago

If I have 2 different forms with input fields with the same names. The data-validation-optional-if-answered validator gets confused when there are such duplicates. Isn't it supposed to look at the named input of it's own form or is this by design?

victorjonsson commented 6 years ago

Looking at the code it should do exactly as you say, it should only try to find the referred input within the same form. Do you have any example code I can look at?

WingGithub commented 6 years ago

It will take some to to extract sample working code from the project as I'm letting the backend do validation and the priority is deliverables. Debugging into the code, there is four forms with the same input names, each in a bootstrap modal that is hidden till needed. Is there a way to load non-minimized logic.js? I can't tell what is going on but it seems the formUtils.getValue() calls in logic.js gets a list of the four forms, along with all the other forms in the page and gets the input from first form of the four.

WingGithub commented 6 years ago

Please look for comment below at the a.formUtils.getValue() /** File generated by Grunt -- do not modify <---- logic.js

This sequence of events is triggered when the modal is displayed, begining at line 1459 of the main https://cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.77/jquery.form-validator.js script: .trigger('beforeValidation', [value, language, conf]);