Home > Blockchain >  validation field with formik
validation field with formik

Time:11-16

I am using a form with react-bootstrap, formik and yup.

enter image description here

Do you have a solution to correct this problem?

CodePudding user response:

you need to use handleBlur and touched to solve this issue

https://stackblitz.com/edit/formik-reactbootstrap-validation-tdkizk?file=src/App.js

<Form.Control
    value={formikProps.values.comment || ''}
    onChange={formikProps.handleChange}
    onBlur={formikProps.handleBlur}
    as="textarea"
    rows={3}
    name="comment"
    isInvalid={
      !!formikProps.touched.comment &&
      !!formikProps.errors.comment
    }
 />
  • Related