-
Notifications
You must be signed in to change notification settings - Fork 55
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
Question: Custom validate method #112
Comments
Hi @hshelbur,
That's one way to do it! This library is only concerned with managing form state giving you the freedom to build and render your own forms however you want (including rendering custom errors).
The errors you're describing here are implemented and displayed natively via the browser (by using the That said, you could still totally set custom errors via this library, but you'd have to use the native validation API, so I understand that it may not be very intuitive at first. The 3rd argument of the validate method is the change event which gives you access to the underlying DOM node. You can use this to call Here's an example to demonstrate how this could be implemented: https://codesandbox.io/s/setcustomvalidity-v2ue3 I hope this helps! |
I am returning an error in a validation function, however the form will still submit and the error is not displayed similarly to the 'Please fill out this field.' error message for required fields or the minimum length generated error message.
Is the current functionality that I must just check for any errors in my handleSubmit function and display these errors on my own, or am I not implementing this correctly? Simple code example:
Great library by the way, thanks!
The text was updated successfully, but these errors were encountered: