I have a html form, which like this:
I have 2 fields, name and email, and 2 buttons, “add row” and “submit”.
When i click the “add row” button, it will create a new row with 2 new fields (name and email). I store the name and email in array: …
Thus, user can ad unlimited rows. I want to have a validation, if the user fill in either name or email on the same row, i want the user to fill in another field, so that every row would have “name” and “email” filled.
How to validate that, if 1 of the field is filled, then the another field on the same row must be filled, in jquery??
First, let’s assume that your rows are divs with a
class="row", and the two fields also has classes asfnameandfemail.Then, the script will be the following: