Last active
March 30, 2020 16:11
-
-
Save cybercris/6e2cc9600dc7b65b7fc1ef2824b07a11 to your computer and use it in GitHub Desktop.
html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form onSubmit={formik.handleSubmit}> | |
<h5>Handling dynamic validation with formik and yup</h5> | |
<div | |
className="text" | |
style={{ backgroundColor: valid ? "green" : "red" }} | |
> | |
Valid Data: {"" + valid} | |
</div> | |
<input | |
type="text" | |
name="otherData" | |
value={formik.values.otherData} | |
onChange={handleChange} | |
onBlur={formik.handleBlur} | |
/> | |
<button type="submit">Submit</button> | |
<br /> | |
{!valid && formik.touched.otherData && ( | |
<div className="blackText">this field is required</div> | |
)} | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment