Example Form Validation, With Section Error

The form below uses multiple techniques to indicate form field errors.

Live region messages — considered to be status messages on this page — are on a delay of two seconds, so that messages are less likely to get clobbered by the screen reader, which may be dealing with announcements that result from focus changes. We have noticed some screen readers do not acknowledge live region messages when they occur simultaneously with changes of focus.

The live region messages on this page target a single element always (no redundant or forgotten live regions for the screen reader user to discover) and are visually hidden by default. If you want to hear the live region messages in action, try using a screen reader to test real-world behavior. This is the best way to test this experience, since other screen reader chatter may be present, due to things like the aria-describedby associated helper and error message changes being treated by some browsers as live region updates. If you want to see the live region messages visually, you can

The error and helper/formatting text below the fields are aria-hidden in order to minimize chatter when browsing the form with a screen reader. If you want to make them always browseable by screen readers in order to test the experience, you can

When in a text field, validation runs on each key-up event, except Tab key. So we can clear the error as soon as the field's validation pattern is met.

Note: Error checking in this form is not very robust. Most of the fields are just looking for some text to go in them, except for the email, zip, and state abbreviation fields, which match on particular patterns. There is no checking if a zip or state abbreviation is correct. The (optional) textarea field is checking for a character count. The radio button group is checking to see if one of the radio buttons is checked.

Personal Information








Favorite Type of Cat