Formik: Formik with Yup is not validating onBlur and onChange

Created on 23 Jul 2019  路  3Comments  路  Source: formium/formik

馃悰 Bug report

My form using yup and is not validating onBlur and onChange on . It validates only onSubmit. How to solve this?

Current Behavior

yup validation not triggered onchange of
when I submit an invalid form (and the validation errors start showing), then onChange validations start working. As I press a key, the validation takes place immediately. So I must be missing something in this fiddle example.

Expected behavior

Form should show errors messages onBlur of

Reproducible with this example

Here I added 3 fields - name {html input}, email { Field component with custom handler} , password { component handles change event using props }

https://codesandbox.io/s/formik-with-yup-bbgbz

Suggested solution(s)

Please allow validateOnBlur or ValidateOnChange for

Additional context

I saw this closed issue, https://github.com/jaredpalmer/formik/issues/1442
Want to know, how to deal this business use case.

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 1.5.4
| React | 16.8.6
| TypeScript |
| Browser |
| npm/Yarn | 10.15.0
| Operating System | windows 7

Most helpful comment

I'm pretty sure you have to add the onBlur listener to your fields. For example

onBlur={formProps.handleBlur}

All 3 comments

Hi,

The codesanbox link is broken.

I'm pretty sure you have to add the onBlur listener to your fields. For example

onBlur={formProps.handleBlur}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredpalmer picture jaredpalmer  路  3Comments

ancashoria picture ancashoria  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

najisawas picture najisawas  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments