formik and yup

Solutions on MaxInterview for formik and yup by the best coders in the world

showing results for - "formik and yup"
Jihane
06 Aug 2016
1import React from 'react';
2 import { Formik, Field, Form, ErrorMessage } from 'formik';
3 import * as Yup from 'yup';
4 
5 const SignupForm = () => {
6   return (
7     <Formik
8       initialValues={{ firstName: '', lastName: '', email: '' }}
9       validationSchema={Yup.object({
10         firstName: Yup.string()
11           .max(15, 'Must be 15 characters or less')
12           .required('Required'),
13         lastName: Yup.string()
14           .max(20, 'Must be 20 characters or less')
15           .required('Required'),
16         email: Yup.string().email('Invalid email address').required('Required'),
17       })}
18       onSubmit={(values, { setSubmitting }) => {
19         setTimeout(() => {
20           alert(JSON.stringify(values, null, 2));
21           setSubmitting(false);
22         }, 400);
23       }}
24     >
25       <Form>
26         <label htmlFor="firstName">First Name</label>
27         <Field name="firstName" type="text" />
28         <ErrorMessage name="firstName" />
29         <label htmlFor="lastName">Last Name</label>
30         <Field name="lastName" type="text" />
31         <ErrorMessage name="lastName" />
32         <label htmlFor="email">Email Address</label>
33         <Field name="email" type="email" />
34         <ErrorMessage name="email" />
35         <button type="submit">Submit</button>
36       </Form>
37     </Formik>
38   );
39 };
40
41export default SignupForm;
queries leading to this page
formik and yup react nativeyup formikusing onchange in react js and yup formikformik with yup react nativeformik yup use component state reactyup validation schema example not for a formwhat it yup formikformik yup examplereact form validation with formik and yup formik and you with reactreact formik with yupinstall formik and yup in reactformik with yup react jsyup 2b formik 2b reactyub reactjs formikformik yup reactjsformik place the yep validationschema reusablleformik with yupuseformik validation schema with yupuseformik validationformik and yup reactjsvalidationschema yup react classnode react form validation with formik and yupformik and yup form validationformik validation in jsxformik with yup exampleformik and yup reactuse formik with yupformik react yup examplereact formik yuphow to use validation schema in useformikbest way formik in formik reactuse validation schema with useformik hookinstall formik and yup reactformik vs yupreact formik and yupformik example react form with yupreact forms with formik and yupformik and yup validationformik and yup in reactformik and yup react native exampleyup in formiknodejs react form validation with formik and yupyup username validationform validation using formik and yup in reactreact bootstrap formik yupformik yupform with formik and yup in reactreact forms using formik and yupformik yup reactapi formik yup reactjsuseformik hook with yupformik 2b react 2b yupinstall formik and yup 5bformik and yupyup with formikformik yup validationyup and formikformik using yup formik yup documentationformik and yup with react nativeformik and yup in react nativereactjs yup without formikyup validation with useformikyup with useformikformik and yup