Accessibility Quick Check

Custom Form Validation

Native browser validation fires one alert at a time and breaks focus management. This review shows how custom JavaScript validation fixes the experience for keyboard users.

Read the full transcript ↓

What Is It?

Native browser form validation shows one alert at a time on submit, with no styling, no focus management, and no way to see all errors at once.

Why It Matters

Keyboard users depend on consistent focus management and inline error messages to understand what went wrong and where to fix it. Native browser alerts fail on both counts.

How To Test

  1. Tab through the form without entering any values.
  2. Press Enter or click Submit.
  3. Observe whether all required field errors appear at once.
  4. Check whether focus moves to the first error field.
  5. Confirm error messages are inline and styled consistently.

The Fix

Adding noValidate to the form disables the native browser alert. Custom JavaScript validation then shows all required field errors simultaneously, inline, with focus moved to the first error field. Three ARIA attributes complete the fix:

  • aria-invalid — marks the field as failed
  • aria-describedby — connects the field to its error message
  • role="alert" — announces the error to screen readers immediately

This satisfies WCAG 3.3.1 and 3.3.3.

WCAG Reference

Related Skills

  • Accessibility Testing
  • Custom JavaScript Validation
  • ARIA Attributes
  • Keyboard Navigation