Skip to content

Conversation

enaeseth
Copy link
Contributor

The validator element() method delegates to check(). When check() is passed a radio or checkbox input element (call it A), it instead checks the first element with the same name in the form (call it B).

If element B is judged invalid, the bug occurs. Element A will have been added to the currentElements array, but element B is what is added to the errorList. So, when showErrors is called, element A will be in validElements(), and will be unhighlighted.

This is fixed by having element() also change its target to be the first element of the same name when passed a checkbox or radio input, so that the element which is added to currentElements is the element which is actually checked.

The validator element() method delegates to check(). When check() is
passed a radio or checkbox input element (call it 'A'), it instead
checks the first element with the same name in the form (call it 'B').

If element B is judged invalid, a bug occurs. Element A will have been
added to the currentElements array, but element B is what is added to
the errorList. So, when showErrors is called, element A will be in
validElements(), and will be unhighlighted.

This is fixed by having element() also change its target to be the
first element of the same name when passed a checkbox or radio input.

Signed-off-by: Eric Naeseth <eric@thumbtack.com>
@jzaefferer
Copy link
Collaborator

Patch looks good. Wondering if its reasonable to create a unit test for the issue. Could you take a look at that? Or @hdragomir?

@hdragomir
Copy link
Contributor

On this.

@enaeseth
Copy link
Contributor Author

@hdragomir: Thank you! I pulled the test commit into my feature branch.

@jzaefferer
Copy link
Collaborator

Thanks guys, landed! Did some rebasing to get this into one commit and include an update to the changelog.

hdragomir pushed a commit to hdragomir/jquery-validation that referenced this pull request Sep 20, 2011
…ckbox input

The validator element() method delegates to check(). When check() is
passed a radio or checkbox input element (call it 'A'), it instead
checks the first element with the same name in the form (call it 'B').

If element B is judged invalid, a bug occurs. Element A will have been
added to the currentElements array, but element B is what is added to
the errorList. So, when showErrors is called, element A will be in
validElements(), and will be unhighlighted.

This is fixed by having element() also change its target to be the
first element of the same name when passed a checkbox or radio input.

Signed-off-by: Eric Naeseth <eric@thumbtack.com>
mlynch pushed a commit to mlynch/jquery-validation that referenced this pull request Mar 28, 2012
…ckbox input

The validator element() method delegates to check(). When check() is
passed a radio or checkbox input element (call it 'A'), it instead
checks the first element with the same name in the form (call it 'B').

If element B is judged invalid, a bug occurs. Element A will have been
added to the currentElements array, but element B is what is added to
the errorList. So, when showErrors is called, element A will be in
validElements(), and will be unhighlighted.

This is fixed by having element() also change its target to be the
first element of the same name when passed a checkbox or radio input.

Signed-off-by: Eric Naeseth <eric@thumbtack.com>
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

Successfully merging this pull request may close these issues.

3 participants