Programming foundations

Build a form that works with keyboard and errors

Make labels, validation, and status messages part of the first implementation.

The decision

Forms should remain usable without a mouse and without guessing what a placeholder means. A visible label names the field even after someone starts typing. Error messages should explain the next action, and asynchronous status changes should be announced without moving focus unexpectedly.

A worked example

An email signup has a label, email autocomplete, a required consent checkbox, and a submit button with a pending label. A failure message says that signup is unavailable and points to the free sample that remains accessible. Success asks the person to check their inbox rather than claiming they are subscribed before confirmation.

How to put it into practice

  1. Connect each label to a unique field ID. Repeated forms on one page need distinct IDs.
  2. Use native controls where possible. They provide keyboard and focus behavior you otherwise have to recreate.
  3. Use role="alert" for actionable errors and role="status" for routine progress or success.
  4. Test zoom, a narrow viewport, and tab order. A visual overlay must not cover its own close control.

A failure to plan for

A disabled button without an explanation can trap users. Re-enable it after a failed request, preserve entered values, and ensure that the error appears in a place a screen reader can discover.

Try it on your project

Complete the form using only Tab, Shift+Tab, Space, and Enter. Trigger an error and then recover. Verify that you can reach privacy details, understand the consent wording, and find the confirmation status.

Primary reference

Read the official documentation →

Keep the next step small

Use the free demand scorecard or planning tools to make your assumptions explicit. The $19 launch kit brings the blueprint and seven editable worksheets together.

Keep learning