Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed validation for named array within form validation (works for name="xyz" and name="xyz[]") both #2000

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

saurabhiam
Copy link

@saurabhiam saurabhiam commented Apr 25, 2017

Description

If a form input has a name="xyz[]" then only first element with name="xyz[]" is validated and rest are ignored.
This fix adds the flexibility for validating the named array (name="xyz[]") or a single name attribute (name="xyz") with no extra effort

Thank you!

@saurabhiam saurabhiam closed this Apr 26, 2017
@saurabhiam saurabhiam reopened this Apr 26, 2017
@saurabhiam saurabhiam changed the title Fixed validation for name array within form. Fixed validation for named array within form validation (works for name="xyz" or name="xyz[]") Apr 27, 2017
@saurabhiam saurabhiam changed the title Fixed validation for named array within form validation (works for name="xyz" or name="xyz[]") Fixed validation for named array within form validation (works for name="xyz" and name="xyz[]") Apr 27, 2017
@saurabhiam saurabhiam changed the title Fixed validation for named array within form validation (works for name="xyz" and name="xyz[]") Fixed validation for named array within form validation (works for name="xyz" and name="xyz[]") both Apr 27, 2017
@saurabhiam
Copy link
Author

Build is failing because of missing spaces after ( ) and a new line before comment. rest is fine

@saurabhiam saurabhiam closed this Apr 27, 2017
@saurabhiam saurabhiam reopened this Apr 27, 2017
@saurabhiam saurabhiam closed this May 3, 2017
@gimler
Copy link

gimler commented Jul 5, 2017

@Saurabh-Sharma i run into the same issue. Your patch works for me. why did you close this PR?

@saurabhiam saurabhiam reopened this Jul 11, 2017
Saurabh-Sharma and others added 2 commits July 11, 2017 12:27
If a form input has a name="xyz[]" then only first element with name="xyz[]" is validated and rest are ignored.
@saurabhiam
Copy link
Author

@gimler Reopened, need to update test cases

@saurabhiam
Copy link
Author

@cmcawood Here it is #2000

@aivils aivils mentioned this pull request May 29, 2018
@stale
Copy link

stale bot commented Jun 5, 2018

This issue/proposal has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and one of the maintainers will (try!) to follow up.
Thank you for contributing :)

@stale stale bot added the stale Used to mark stale issues label Jun 5, 2018
@gimler
Copy link

gimler commented Jun 6, 2018

still an issue the fix works

@stale stale bot removed the stale Used to mark stale issues label Jun 6, 2018
@saurabhiam
Copy link
Author

Checks are failing due to test cases, which are expecting validation on single field. which is exactly not the case here.

>> validator - validating multiple checkboxes with 'required'
>> Message: null
>> Actual: 5
>> Expected: 1
>> file:///home/travis/build/jquery-validation/jquery-validation/test/test.js:1098:14

>> events - validate multiple checkbox on click
>> Message: null
>> Actual: 2
>> Expected: 1
>> errors@file:///home/travis/build/jquery-validation/jquery-validation/test/test.js:1917:15
>> file:///home/travis/build/jquery-validation/jquery-validation/test/test.js:1941:8

>> events - validate radio on click
>> Message: null
>> Actual: 2
>> Expected: 1
>> errors@file:///home/travis/build/jquery-validation/jquery-validation/test/test.js:1976:15
>> file:///home/travis/build/jquery-validation/jquery-validation/test/test.js:1994:8

@fansanelli
Copy link

@Saurabh-Sharma Hi,
I've applied you patch and it seems to workaround the issue without fixing it.
I suggest to add an "index" property in the "element" object using the jquery .index() method, then change the find-by-name function to accept it:
return $( this.currentForm ).find( "[name='" + this.escapeCssMeta( name ) + "']:eq(" + index + ")" );
I'm not familiar with the validator code, but if you cannot give it a try I could to hack around my idea.
What do you think?
Cheers,
Francesco

@gimler
Copy link

gimler commented Sep 26, 2018

1.18.0 still in issue. The PR works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants