📊 We use cookies & analytics to improve your experience. Learn more
Latest

React & Modern Front-End Development Module 5 · Lesson 13 of 15

0% Exit to course

Module 5 · Forms, performance and access Lesson 13 of 15

Forms with validation and clear errors

Learning objective

A form that validates on the client and shows one clear message per field is the difference between a sign-up and a bounce. Keep the values in state, validate on submit, show the error next to the input.

Worked example

errors.email = 'Enter a valid email' is set on submit, and the input renders aria-invalid and the message, so a screen reader hears it too.

Your practice task

Build a sign-up form with three fields, validate them on submit, and show the first error next to its field.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

A form that validates on the client and shows one clear message per field is the difference between a sign-up and a bounce. Keep the values in state, validate on submit, show the error next to the input.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.

Next recommended course Full-Stack Web Development Bootcamp