Skip to the page

Forms, colour and motion · core

Accessible forms: labels, hints, errors and autocomplete

Every form control needs a visible, programmatically linked label; hints and errors are linked with aria-describedby, invalid fields get aria-invalid, errors are shown in text (not colour alone) and focus goes to the first error or an error summary on submit; autocomplete and input types help everyone fill forms faster.

The notes

What you must know

  • <label for="pin">PIN code</label><input id="pin">, or wrap the input in the label. Placeholder is not a label. Group related controls (radio buttons, address) with <fieldset> and <legend>.
  • Hints and errors: <p id="pin-hint">6 digits</p>, error <p id="pin-error">Enter a valid 6-digit PIN code</p>, then aria-describedby="pin-hint pin-error" and aria-invalid="true" on the input.
  • On submit with errors: move focus to the first invalid field, or to an error summary at the top with links to each field (good for long KYC forms). Inline validation should not shout on every keystroke; validate on blur or submit.
  • Required fields: the native required attribute (or aria-required) plus a visible marker explained once.
  • autocomplete tokens (email, tel, postal-code, one-time-code, cc-number) satisfy WCAG 1.3.5 and help autofill; inputmode="numeric" shows the number keypad.
  • WCAG 2.2: Redundant Entry (don't ask again for info already given in the process) and Accessible Authentication (allow paste and password managers, don't block OTP paste).
  • In React, generate ids with useId so label, hint and error ids are unique.

The red pen

Common traps: mistake → fix

  • Mistake: "Red border shows the error"

    Fix: colour alone fails users who can't see it; add text and an icon, and aria-invalid.

  • Mistake: "Disable the submit button until the form is valid"

    Fix: users can't find out what's wrong; let them submit and show errors.

  • Mistake: "Block paste in OTP/password fields for security"

    Fix: it breaks password managers and fails Accessible Authentication.

Easy to hard

Questions interviewers ask, easy to hard

  1. Build an accessible signup form with inline validation.
  2. How do you link an error message to its input?
  3. What should happen to focus when the user submits a form with three errors?
  4. Make a 30-field KYC form accessible and fast.

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview