-
Notifications
You must be signed in to change notification settings - Fork 126
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
Trigger validations onSubmit vs onBlur option #93
Comments
@th3fallen I am currently using formsy to only show the messages after a user leaves the input (instead of on typing). The validations are still done as the user types but I am only showing them after the user modifies the input or clicks the submit button. I control that in my input wrapper component by choosing when the error message gets displayed or not. Something like:
Note that isFieldEdited is part of my component and isFormSubmitted() is from Formsy. |
I've been wanting this for a long time too. What @mikelyncheski suggest is certainly possible and a good way to do it, but sometimes you may want to optimize a demanding validation by not doing it on every keyup. Debounce would also be another nice option. We could probably add this as a non-breaking change as a prop which works as before by default, something like:
with 'keyup' as default, or whatever is the default atm |
Ok, we're all stupid. Sorry for calling you stupid, but I'm calling myself stupid too so it's fine ;) Upon further investigation turns out this is up to the implementation of a formsy field component.
|
As a followup on this one. When you use onBlur to set the error, a common pattern is to clear the error when the user starts typing.
Right now, it seems that Formsy does not internally handle steps 4-5, correct. |
Is there any solution for this issue? |
@hungbang There is currently no solution for this issue, but PRs are welcome as well as failing tests or even just edits to |
Hi, I wanted to implement this behavior so I went through the source code of formsy and came up with this solution, but I don't know much about the structure and the way formsy validates the forms in it's internals (frankly don't have that much time), but it seems to be working as expected. That's why i wanted to ask @rkuykendall if this is a possible proof of concept that could be implemented. ValidationInput.js
And the form source code:
EDITAdded onKeyDown check for validation of the input on |
is this currently possible?
The text was updated successfully, but these errors were encountered: