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

Calling .blur() on ignored field inside invalidHandler() cause the form to becomes valid #700

Closed
jackysee opened this issue Mar 21, 2013 · 1 comment

Comments

@jackysee
Copy link

I have a form validate configured with an invalidHandler, which would trigger blur() on an <select> inside the form. The <select> is configured to be ignored by the validator.

However, when calling .valid(), even when there is another invalid field, it still returns true.

Check this fiddle as the example:
http://jsfiddle.net/cBwzN/1/

@ruado1987
Copy link
Contributor

This weird behaviour is occurring because when you call blur method on the select element in the invalidHandler, jquery-validation will internally trigger the onfocusout event whose handler will call the prepareElement method which in turn calls the reset method. It is this method that wipes out all the error reported so far in the validation process. ATM, you can work around this problem by adding onfocusout: false to the option passed to the validate method. I updated your jsFiddle with this workaround.

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

2 participants