This repository has been archived by the owner on Nov 10, 2018. It is now read-only.
Change checkboxes and radios to validate on click #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This library has made the choice to validate inputs on blur; this is a totally reasonable choice for normal text inputs as it stops potential off-putting switching between validity states as the user types. For radios and checkboxes though there’s no typing to be done, yet the library still waits for a blur event (i.e. a click somewhere else or a tab away) before updating the visual validity state.
This commit adds a click event handler for radios and checkboxes that will evaluate the validity immediately after the browser changes the internal state of the control. This provides immediate feedback to the user that they’ve corrected the problem.
Example without this change (this is particularly bad as it’s using a custom form control that is basing its styling on
![A screen capture of the behaviour without this patch](https://user-images.githubusercontent.com/7414/30332239-20a30f18-97da-11e7-8166-983747d6b7b7.gif)
validate
’s state):Example with this change:
![A screen capture of the behaviour with this patch](https://user-images.githubusercontent.com/7414/30332290-3adece30-97da-11e7-91bf-8a15be538c6c.gif)