Sign-up form with validation
A controlled form that checks the email and password before submitting.
intermediateReact
The task
Build a SignupForm with an email and a password field (controlled inputs).
When the form is submitted:
- Stop the page from reloading.
- If the email has no
@, show "Enter a valid email." - If the password is shorter than 8 characters, show "Use at least 8 characters."
- If both are fine, show "Welcome!" instead of the form.
Show each error under its field.
What you'll build
The finished result. Try it out, then build it yourself below.
Demo · drag the bottom edge to make it taller