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

I can't validate form with multi array names #2310

Closed
maciekwyka opened this issue Jan 9, 2020 · 3 comments
Closed

I can't validate form with multi array names #2310

maciekwyka opened this issue Jan 9, 2020 · 3 comments

Comments

@maciekwyka
Copy link

Subject of the issue

I have form where user can dynamically add or remove rows, names of input files is for example "colorkeeper_project[rooms_attributes][][surfaces_attributes][][name]"
I have no idea how to deal with it, when I make rule for "colorkeeper_project[rooms_attributes][][surfaces_attributes][][name]" only the first row is validating.

Your environment

  • version of jquery-validate: 1.16.0
  • which browser and its version: Safari 13.0.4
@s-fraser2007
Copy link

Hi, I was having this same issue, I came accross this
http://www.codeboss.in/web-funda/2009/05/27/jquery-validation-for-array-of-input-elements/
Works nicely

@thejoker-dev
Copy link

Using jquery validate 1.19.1 and modifying the jquery.validate.js file on line 465, replacing with this function should be fine.

checkForm: function() { this.prepareForm(); for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) { var checkingElements = this.findByName( elements[i].name ).not(this.settings.ignore); if (checkingElements.length !== undefined && checkingElements.length > 1) { for (var cnt = 0; cnt < checkingElements.length; cnt++) { this.check( checkingElements[cnt] ); } } else { this.check( elements[i] ); } } return this.valid(); },

I hope to be of help ;)

@bytestream
Copy link
Member

Duplicate of #2326 (comment) which has better reproducer and description of issue.

Suggest to close.

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

No branches or pull requests

4 participants