Skip to content

Error in not validating array's of inputs correctly. #2326

Closed
@thejoker-dev

Description

@thejoker-dev

Subject of the issue

The error occurs in the instance of validating a form with array's of equal inputs, it only validates the first element found within the form.

Your environment

  • version of jquery-validate: 1.19.1
  • version of jquery: 3.4.1
  • which browser and its version: Google Chrome v81.0.4044.122 (Build oficial) (64 bits)

Steps to reproduce

http://jsfiddle.net/thejoker_dev/p6zs51v8/

Expected behaviour

It should validate all types of inputs, including those that are arrays of themselves.

Actual behaviour

Validates only the first input of the array with the same name, leaving the rest unvalidated.

Attached jquery-validate.js file modified on line 465 (checkForm function) which I leave below and it works without problems!

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(); }

Attached jquery-validate.js file modified on line 465 (checkForm function) which I leave below and it works without problems!

jquery.validate.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleUsed to mark stale issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions