Skip to content

Instantly share code, notes, and snippets.

@scottgamer
Last active March 16, 2021 03:24
Show Gist options
  • Select an option

  • Save scottgamer/8510fc51bc4ffea36fc37232d985eefd to your computer and use it in GitHub Desktop.

Select an option

Save scottgamer/8510fc51bc4ffea36fc37232d985eefd to your computer and use it in GitHub Desktop.
form with error messages
<Formik
initialValues={initialValues}
onSubmit={onSubmit}
validationSchema={validationSchema}
>
<Form className="form">
<label htmlFor="firstName" className="form__label">
First Name
</label>
<Field
name="firstName"
type="text"
className="form__input"
placeholder="First Name"
/>
<ErrorMessage
name="firstName"
component="span"
className="form__error"
/>
<label htmlFor="lastName" className="form__label">
Last Name
</label>
<Field
name="lastName"
type="text"
className="form__input"
placeholder="Last Name"
/>
<ErrorMessage
name="lastName"
component="span"
className="form__error"
/>
<label htmlFor="email" className="form__label">
Email
</label>
<Field
name="email"
type="text"
className="form__input"
placeholder="Email"
/>
<ErrorMessage name="email" component="span" className="form__error" />
<button type="submit" className="btn">
Submit!
</button>
</Form>
</Formik>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment