简体   繁体   中英

Formik + Yup - Show error as user is typing in

I have an email field and I am validating its uniqueness as the user types in ie is the email the user is typing available. Currently, I only get the error message when the user loses focus of the field (onBlur) but I want formik to show errors while the user is typing in. I've read that showing errors on losing focus on the field is the 'default' behavior of formik but I was hoping maybe there was a way to achieve what I want?

You can use Formik's validateOnChange prop to trigger validations on every change event

See here for details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM