React Formik - Trigger validation only on form submit
Check the docs
You can control when Formik runs validation by changing the values of
<Formik validateOnChange>
and/or<Formik validateOnBlur>
props depending on your needs. By default, Formik will run validation methods as follows:
Pass to your Formik
the props validateOnChange={false}
and validateOnBlur={false}
Yeah. You can do something like this.
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
validateOnChange={false}
validateOnBlur={false}
onSubmit={(values, { validate }) => {
validate(values);
}}
>
If you use useFormik hook, the next config should be added
const formik = useFormik({
initialValues,
validationSchema,
validateOnChange: false, // this one
validateOnBlur: false, // and this one
onSubmit: (values) => {
do something on submit
},
});