Opens in a new tab

Web design

Form validation: error messages that help people finish your form

Where to check a form, how to write error messages people can act on, when to show them and how to make them reach screen readers.

CheckedNovember 5, 2026
Reading time
Part ofWeb design
Listen to this guide
0:00 /6:07

Short answer: Form validation checks what people type before the form is accepted. Check in the browser for fast feedback and again on the server for security. Show each error in text next to its field, after the person finishes it, and mark it with aria-invalid for screen readers.

What form validation does

Validation catches empty required fields and data in the wrong format before they reach you. MDN lists the browser’s own messages, such as “This field is required” and “Please enter a valid email address”.

WCAG criterion 3.3.1, at Level A, covers input errors that are detected automatically. The field in error has to be identified, and the error described to the user in text. Our contact form guide covers which fields to make required.

Browser, script and server

Where the check runs What it does Worth knowing
In the browser required and type="email" stop the send with the browser’s own message Fast, but MDN warns it is too easy to bypass
In your own script Shows your messages by the fields and sets aria-invalid Add styling and a message on how to fix it
On the server Checks the data again before it is stored Browser checks alone don’t ensure security, the W3C says

From MDN’s pages on client-side form validation and aria-invalid and the W3C forms tutorial, read November 4, 2026.

MDN warns that malicious users can still send bad data to your server, because checks in the browser are too easy to bypass.

How to write error messages

NN/g recommends showing each message below or next to the field in error. The message should be explicit, human-readable, polite and precise, and give constructive advice.

Criterion 3.3.3, at Level AA, asks you to suggest a fix when you know one, unless that would put the security or purpose of the content at risk. “Enter an email such as name [at] example.com” helps more than “Invalid input”.

NN/g notes that red is the color most associated with errors, and that an icon helps people who are colorblind. The W3C accepts color or an image in addition to the text, never in its place.

When to show the error

NN/g recommends inline validation: as soon as someone finishes a field, an indicator appears nearby if the field has an error. It also advises against showing an error before the person has finished with the field.

Some checks can only run after the form is sent. In that case, show each message next to its field and make the fields in error easy to find.

Errors and screen readers

A red border means nothing to someone who can’t see it. MDN asks your own validation scripts to set aria-invalid on fields in error, together with visible styling and a message that explains how to fix the mistake.

MDN also says not to set aria-invalid on an empty required field until the person tries to send the form. It suggests linking the message with aria-errormessage. Our aria-label guide shows how fields get their names.

How to add validation to a form

  1. Mark required fields in their visible labels and with the required attribute.
  2. Use input types such as type="email" so the browser runs basic checks.
  3. Check the same data again on the server before you store it.
  4. Show each error in text next to its field, once the person finishes the field.
  5. Say how to fix the problem, with an example when it helps.
  6. Set aria-invalid on fields in error and link each one to its message; wait for a send before marking empty required fields.
  7. Remove the marks when the field is fixed, and test the whole form with a keyboard.

How our own form reports errors

On November 4, 2026, we tried our contact form in both languages, at computer and phone widths. No message left the test browser. We pressed “Send message” with the name, phone and email empty.

Each of those fields showed its message underneath, and the focus moved to the first one. With the earlier version of our form, nothing told a screen reader which fields were wrong. When a send failed, the keyboard focus also fell back to the page.

After the change we made that day, each field with an error carries aria-invalid and points to its message with aria-describedby. Typing a valid email cleared that field’s marks, and the other two kept theirs. When a send fails, the focus stays on the button, and a line says “Could not send. Please try again.”

Before you publish

  • Required fields say so in their labels.
  • Every error appears in text next to its field.
  • No error shows while someone is still typing.
  • Fields in error carry aria-invalid and point to their message.
  • The server checks the data again.
  • A failed send says so in text.

RememberAn error message is part of the form. Put it next to the field, say how to fix the problem, and make sure screen readers get it as well.

We build forms like this in our web design service. Our WCAG 2.2 guide covers the rest of the accessibility standard.

Quick answers about form validation

What is form validation?

Checking what someone typed before the form is accepted: that required fields are filled in and that an email or a date has the right format. When a check fails, the form says which field is wrong and how to fix it.

Should I validate in the browser or on the server?

Both. Checks in the browser give fast feedback, but MDN warns they are too easy to bypass. The W3C adds that browser checks alone don’t make a form secure, so the data has to be checked on the server too.

When should an error message appear?

After the person finishes a field, not while they are still typing. NN/g recommends inline validation once a field is complete. MDN adds that an empty required field shouldn’t be marked with aria-invalid until the person tries to send the form.

Where should an error message go?

Next to the field that has the problem, usually below it. NN/g says the message should be explicit, polite and precise and give constructive advice. WCAG asks that the error is described in text, not only with color.

How does a screen reader know that a field has an error?

Mark the field with aria-invalid="true" and link it to its error message. MDN asks your own validation scripts to add aria-invalid together with visible styling and a message that explains how to fix the mistake.

Sources

Read on November 4, 2026. W3C Web Accessibility Initiative: Understanding SC 3.3.1 Error Identification (Level A), Understanding SC 3.3.3 Error Suggestion (Level AA) and the forms tutorial Validating Input. MDN Web Docs: Client-side form validation and ARIA: aria-invalid attribute. Nielsen Norman Group: 10 Design Guidelines for Reporting Errors in Forms. Our case: the contact form on our site, checked on November 4, 2026.

Pedro Galindez

Pedro Galindez

Founder of Feedback Studios, a bilingual growth studio in Miami.

Listen0:00 /6:07

More guides

Checked November 5, 2026

Color blindness simulator: how to check your website for color blind visitors

How to simulate color blindness in Chrome, what WCAG asks about color, and where color alone causes trouble on a website.

Checked November 5, 2026

Dyslexia-friendly font: what actually helps people read your website

Whether dyslexia fonts work, what the evidence says, and the changes to layout, writing and format that help readers with dyslexia more.

Checked November 5, 2026

Screen reader: what it is and how to test your website with one

What a screen reader does, which ones people use, how it reads your page and how to test your own site with one.

Checked November 4, 2026

HTTP/2 and HTTP/3: what they change for your website

What HTTP/2 and HTTP/3 change from HTTP/1.1, what Google says they do for SEO, how to check your site and what our site and the crawlers use.

Checked November 4, 2026

AI crawlers: which bots visit your website and how to control them

Training, search and user bots from OpenAI, Anthropic, Perplexity, Google and Apple, how robots.txt controls them and which ones visited our site.

Next step

Tell us what you need

Write to us on WhatsApp or send us a message. We answer in English or Spanish.