Home / Fix guides / Accessibility (WCAG)

How to make form error messages accessible to screen readers

Form error messages are accessible when each one is written as text, tied to its field in the code, and announced the moment it appears. If a screen reader user hears nothing after pressing Send, your form has this problem.

When a visitor submits a form with a mistake, a sighted person sees red text and fixes it. A screen reader user may hear nothing at all. The page looks changed on screen, but the software reading it aloud was never told, so they don't know the form failed or which field needs attention.

The good news is that this is usually a small, well understood fix. It is about connecting each error message to its field and making sure the error is announced when it appears.

What people see

The typical story: someone fills in your contact or checkout form, presses the button, and nothing seems to happen. On screen, red text has appeared near a field. For a screen reader user, focus is still on the button and no message was spoken. Other common versions:

  • The only sign of an error is a red border or red text colour, with no written message.
  • The error appears at the top of a long page, out of view and unannounced.
  • A message flashes up for a few seconds and disappears.
  • The message is on screen, but not linked to the field it belongs to, so the field is just announced as "edit text".

Why it matters

People who can't tell what went wrong give up, and you lose the enquiry, booking or sale. It also hurts others: keyboard users, people with low vision, and anyone on a small phone screen benefit from clear, nearby error text.

There is also a standards angle. WCAG (the Web Content Accessibility Guidelines) covers this in three places: 3.3.1 Error Identification (Level A), 3.3.3 Error Suggestion (Level AA) and 4.1.3 Status Messages (Level AA). Many accessibility policies and contracts refer to WCAG, so forms that fail these are an easy thing for an auditor to flag.

How to check your site for free

  1. Keyboard test. Open your form, leave a required field empty, and submit using only Tab and Enter. Can you tell what went wrong and reach the faulty field quickly?
  2. Screen reader test. Try NVDA (free, Windows), Narrator (built into Windows), VoiceOver (built into Mac and iPhone) or TalkBack (Android). Submit a bad form and listen. You should hear that there is an error and what it is, without hunting for it.
  3. Automated checkers. The Lighthouse accessibility audit in Chrome, the WAVE browser extension and axe DevTools are free. They catch some problems, such as inputs with no label, but they can't tell whether an error was actually announced. Treat them as a first pass, not a verdict.
  4. Inspect the code. Right click an error message and choose Inspect. Does the message have an id, and does the matching input have aria-describedby pointing to that id? If not, they are not connected.

If your inputs also have no proper labels, fix that first, see form inputs with no labels.

How to fix it in general

The pattern is the same on any platform:

  1. Write the error as visible text next to the field. Say what is wrong and how to fix it, for example "Enter an email address like name@example.com", not just "Invalid".
  2. Link the message to the field with aria-describedby, and set aria-invalid="true" on the field while it has an error.
  3. Announce the problem when the form is submitted. Either move keyboard focus to a short error summary at the top (give it tabindex="-1" so it can receive focus), or place the summary in a live region such as role="alert". Pick one approach, not both, or the message may be read twice.
  4. Don't rely on colour alone. Add text, and optionally an icon.
  5. Keep the message on screen until the visitor fixes the problem. Don't auto-hide it.
  6. Remove aria-invalid and the message when the field is corrected.

A minimal example:

<label for="email">Email address</label>
<input id="email" name="email" type="email"
       aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Enter an email address like name@example.com</p>

One trap with live regions: the container usually needs to exist in the page before you put text into it. If a script adds the whole element and its text at the same moment, some screen readers stay silent.

Browser built in validation bubbles (the pop ups you get with the required attribute) are announced inconsistently between browsers and screen readers. Many sites turn them off with novalidate and show their own messages using the pattern above.

Common platforms

Where the setting lives depends on your theme, version and form tool, so use these as pointers.

  • WordPress: errors come from your form plugin (for example Contact Form 7, WPForms or Gravity Forms) and your theme. Check the plugin's settings and update it, then test. See the WordPress guide.
  • Shopify: contact, login and newsletter forms come from your theme. Update the theme, test each form, and ask a developer to edit the form template if errors are silent. See the Shopify guide.
  • WooCommerce: checkout and account errors usually appear in a notice block at the top of the page. Test a failed checkout with a screen reader, as results vary by theme.
  • Wix: you have limited control over built in forms. Test them, and if errors stay silent, consider a different form option.
  • Webflow: form error and success messages are blocks you design. You can usually add custom attributes (such as role or aria-live) in the element settings panel.
  • Elementor: the Form widget has its own message options. Test the result, as extra code may be needed.
  • React and similar code: keep error state per field, render the message with an id, set aria-invalid and aria-describedby, and move focus to the first invalid field or a summary on submit.

How to confirm the fix worked

Repeat the same tests. Submit the form empty with only the keyboard. With a screen reader running, you should hear the error (or land on the summary) without searching, and each field should read its own message when you focus it. Fix the error and check that the message disappears and the field is no longer marked invalid. Then try on a phone with VoiceOver or TalkBack, since mobile behaviour can differ. Finally, run Lighthouse or axe again to make sure nothing new was flagged.

How to stop it coming back

  • Build the error pattern once into a shared form component or template, and reuse it for every new form.
  • Add a quick keyboard and screen reader submit test to your launch checklist for any new form, including checkout and login.
  • Retest after theme, plugin or form tool updates, since these often replace the markup.
  • Run a regular accessibility audit. In SiteMonday, week 7 is the WCAG 2.2 accessibility audit, and it ends with a written report and ranked fix list. Fixing is up to you or your developer.

Step by step for your platform

Questions

Do I need role="alert" on every error message?

No. Linking each message to its field with aria-describedby works for field level errors. Use role="alert" or focus management for the summary shown after submitting, and choose one so it isn't read twice.

Is a red border enough to show an error?

No. Colour alone is not available to everyone, and a screen reader will say nothing about it. Always include written text that explains the problem.

Does the HTML required attribute make my form accessible?

Not reliably. Browsers show and announce their built in messages differently, so many sites use their own messages and test them with a screen reader.

Can an automated tool tell me if errors are announced?

Not fully. Tools like Lighthouse, WAVE and axe catch missing labels and some broken links, but you still need to submit a bad form with a screen reader to hear what happens.

Which screen reader should I test with?

Start with what is free and already on your device: NVDA or Narrator on Windows, VoiceOver on Mac and iPhone, TalkBack on Android. Testing with one is far better than none.

Where should keyboard focus go after a failed submit?

Either to a short error summary at the top that links to each problem, or to the first invalid field. Either way, the visitor should know right away that something needs fixing.

Related problems