Accessibility Test

Promotional banner for 'Accessible Form Design | Validation and Error Recovery' article featuring a laptop displaying a form interface. The purple background includes a YouTube subscribe button and the accessibility-test.org logo with tagline 'COMPARE. CHECK. COMPLY.' Two small plants frame the laptop.

Accessible Form Design | Validation and Error Recovery

Banner comparing top accessibility tools with headline 'Compare the Best Accessibility Tools | Updated Weekly'. Shows three recommended tools with ratings: UserWay (8/10) for AI-powered WCAG compliance, AccessiBe (7/10) for automated ADA compliance, and AudioEye (9.5/10, labeled 'Best Overall') offering hybrid solution with automation and expert audits. Last updated February 15, 2025. The page helps users compare features, pricing and benefits for WCAG, ADA, and Section 508 compliance.

Accessible Form Design | Validation and Error Recovery


Forms are a key part of many websites, letting users sign up, buy things, or share information. But poorly designed forms can stop many people from using your website, especially those with disabilities. This article shows you how to build forms everyone can use, with clear steps on how to set up proper validation and ways to help users fix mistakes.

The Anatomy of Accessible Form Fields


Creating forms that work well for everyone starts with building each form field correctly. Each part of a form field plays an important role in helping users understand what information they need to provide.

Label Association Techniques


Every form field needs a proper label that clearly tells users what information they should enter. Without clear labels, users with screen readers might not understand the purpose of a field.

There are two main ways to connect labels with form fields:

  1. Using the “for” attribute: This links the label to the form control using matching ID values.

<label for=”username”>Username</label>
<input id=”username” type=”text”>

  • Nesting the input inside the label: This creates an automatic connection between the label and the form control.

<label>
  Email address
  <input type=”email”>
</label>

Both methods work well, but the first option often creates cleaner code and better layout options. When using either method, make sure the label text clearly describes what information is needed.

Labels should not disappear when a user starts typing. This means you shouldn’t rely only on placeholder text as your label, since this text goes away once a user begins entering information.

Purple banner featuring the text 'European Accessibility Act (EAA) - Step By Step for Businesses in 2025' with a computer screen displaying the EAA logo surrounded by EU stars. Includes a YouTube 'Subscribe' button and Accessibility-Test.org logo with the tagline 'Compare. Check. Comply.' Decorative icons such as gears and code snippets are also visible.

Input Field Accessibility Attributes


Beyond just having labels, form fields need several other features to work well for all users:

Required Field Marking

When some fields are required, you need to clearly show which ones users must fill in. The most clear way to mark required fields is to add “(required)” directly in the label text:

<label for=”email”>Email address (required)</label>

This approach is better than just using an asterisk (*) because it’s clearer to all users, including those using screen readers.

Help Text

Many form fields need extra information to help users understand what to enter. This help text should be connected to the form field using the aria-describedby attribute:

<label for=”password”>Password (required)</label>
<input type=”password” id=”password” aria-describedby=”password-help”>
<p>Use at least 8 characters with a mix of letters, numbers, and symbols.</p>

This connection ensures screen readers will announce the help text when a user focuses on the field.

Input Types and Attributes

Using the right HTML input types helps browsers provide the right keyboard and validation for different kinds of information:

<input type=”email”>
<input type=”tel”>
<input type=”number”>

Adding the autocomplete attribute helps users by filling in information they’ve entered before:

<input type=”text” autocomplete=”name”>
<input type=”email” autocomplete=”email”>
<input type=”tel” autocomplete=”tel”>

This feature is especially helpful for users with memory or motor difficulties, as they won’t need to type the same information repeatedly.

Graphic illustrating 'The Importance of Mobile-First Accessibility Design.' The image features a purple background with the title prominently displayed. Below the title, there is a red YouTube subscribe button labeled 'YouTube Video Included!' On the right, two smartphone screens are shown side by side. The left phone has a cluttered, inaccessible design marked with a red 'X,' while the right phone displays a clean, accessible layout marked with a green checkmark. At the bottom, the Accessibility-Test.org logo and tagline, 'Compare. Check. Comply.,' are displayed.

Implementing Accessible Form Validation


Form validation checks that users have filled in all the required information correctly. When done right, validation helps users complete forms successfully without frustration.

Client-Side Validation Best Practices

Client-side validation happens directly in the browser, providing quick feedback to users. However, there are important rules to follow when implementing it:

When to Validate

The best time to validate a form is when the user tries to submit it by clicking the submit button – not while they’re still typing. Showing errors while someone is in the middle of typing can be frustrating and confusing, especially for:

  • People who type slowly
  • Users with cognitive disabilities
  • People using screen readers
  • Anyone using voice input software

This approach lets users complete their thoughts before seeing any error messages.

Clear Error Messages

Error messages should be specific and helpful, telling users exactly what went wrong and how to fix it:

❌ “Invalid input” (too vague)
✅ “Please enter a valid email address, such as [email protected]

Good error messages use plain language and avoid technical jargon that might confuse users.

Interactive ARIA Widgets | Implementation Guide for Developers" with a purple background. Features the accessibility-test.org logo with tagline "COMPARE. CHECK. COMPLY." at bottom left. Shows illustrations of a computer screen and mobile device on the right, with a person pointing at them. Includes text "YouTube Video Included!" and a red Subscribe button. Decorative plant at the bottom.

Using ARIA to Communicate Validation States


ARIA (Accessible Rich Internet Applications) attributes help screen readers understand the state of form fields, including whether they have errors:

Marking Invalid Fields

When a field has an error, add the aria-invalid=”true” attribute to tell screen readers that something is wrong:

<input type=”email” id=”email” aria-invalid=”true” aria-describedby=”email-error”>
<p>Please enter a valid email address.</p>

The combination of aria-invalid and aria-describedby ensures users will know both that there’s an error and what the error is.

Error Message Connection

Every error message must be connected to its field using aria-describedby:

<div>
  <label for=”phone”>Phone number</label>
  <input type=”tel” id=”phone” aria-invalid=”true” aria-describedby=”phone-error”>
  <p>Please enter a 10-digit phone number.</p>
</div>

This setup ensures screen readers will announce the error message when a user focuses on the field with the error.

Server-Side Validation Error Handling

Server-side validation happens after the form is submitted, checking the data on the server. This type of validation is important for security, but needs to be implemented with accessibility in mind.

When a form fails server-side validation, the page typically reloads with error messages. To make this process accessible:

  1. Display clear error messages at the top of the form
  2. Keep all the information the user already typed in the form
  3. Focus the user’s keyboard on either the error summary or the first field with an error
  4. Make sure all error messages are properly connected to their fields

Server-side validation should work together with client-side validation to create a smooth experience for all users.

Illustration promoting healthcare website accessibility and patient portal requirements. The image features a laptop displaying a patient portal, surrounded by healthcare professionals and patients interacting with digital devices. A clipboard with a heart symbol, a stethoscope, and medical documents are also visible. The text reads, 'Healthcare Website Accessibility | Patient Portal Requirements' and 'YouTube Video Included!' with a red 'Subscribe' button. The logo for accessibility-test.org is displayed at the bottom with the tagline 'Compare. Check. Comply.

Maintaining Form Data After Submission Errors


One of the most frustrating experiences for users is losing all their information after submitting a form with errors. This is especially difficult for users with motor or cognitive disabilities who may have spent significant time filling out the form.

Always keep the user’s input when returning an error:


<input type=”text” name=”username” value=”<?php echo htmlspecialchars($submitted_username); ?>”>

This approach respects users’ time and effort by not forcing them to re-enter information they’ve already provided.

Error Recovery Patterns for Maximum Usability


Even with the best form design, users will sometimes make mistakes. Good error recovery helps all users understand and fix these mistakes easily.

Error Summary Implementation Techniques

When a form has multiple errors, a summary at the top of the page helps users understand all the issues at once. According to best practices from the search results:

For Multiple Errors

When there’s more than one error, create a summary at the top of the form that:

  1. Uses a heading like “There were problems with your submission”
  2. Lists each error with a link to the corresponding field
  3. Has a distinctive appearance (using color, borders, and icons)
  4. Gets keyboard focus when the page loads

Example HTML for an error summary:

<div>
  <h2>There were problems with your submission</h2>
  <ul>
    <li><a href=”#email”>Please enter a valid email address</a></li>
    <li><a href=”#password”>Password must be at least 8 characters long</a></li>
  </ul>
</div>

The links in the summary should jump directly to the corresponding field when clicked, making it easy for users to find and fix each error.

For Single Errors

When there’s only one error, you don’t need a summary. Instead, focus the keyboard directly on the field with the error so users can fix it right away.

ARIA Live Regions for Dynamic Error Messages

Live regions are special areas of a page that can announce changes to screen reader users, even when their focus is elsewhere on the page. They’re perfect for dynamically updating error messages without requiring a full page reload.

Types of Live Regions

There are different types of live regions for different situations:

  1. Status messages (role=”status” or aria-live=”polite”): For non-urgent information like validation feedback. These wait until the screen reader finishes what it’s currently saying before announcing the update.
  2. Alert messages (role=”alert” or aria-live=”assertive”): For urgent information like critical errors. These interrupt the screen reader to announce the message immediately.

Example implementation for form validation feedback:

<div>
  <label for=”username”>Username (required)</label>
  <input type=”text” id=”username” required aria-describedby=”username-status”>
  <div></div>
</div>

<script>
  // When validation runs:
  document.getElementById(‘username-status’).textContent = ‘Username is available!’;
  // Screen readers will announce this message
</script>

The role=”status” attribute creates a live region that will announce updates to screen reader users in a non-intrusive way.

Promotional banner for VPAT Documentation Masterclass 2025 on a purple background. Features the title, YouTube video mention with subscribe button, and accessibility-test.org logo. Right side displays accessibility icons, VPAT compliance badge, and lists four VPAT formats: 508, EU, WCAG, and INT. Includes stylized human figures interacting with accessibility elements.

Best Practices for Live Regions


To use live regions effectively:

  1. Create the live region in the HTML before you need it (don’t add it dynamically)
  2. Update only the text content inside the region, not the region itself
  3. Keep messages clear and concise
  4. Use polite for most form validation messages and assertive only for critical errors
  5. Test with actual screen readers to make sure the announcements work as expected

Live regions are particularly useful for instant feedback during form interactions, such as checking if a username is available or validating a credit card number without a full page reload.

Form Accessibility Testing

Testing is an important step in making sure your forms work for everyone. Here are key things to check:

Keyboard Navigation Testing

Try completing your form using only the keyboard (no mouse):

  • Can you reach all fields using the Tab key?
  • Can you activate buttons with Enter or Space?
  • Do error messages get announced properly?
  • Can you navigate between fields with errors easily?

Screen Reader Testing

Test your form with at least one screen reader:

  • Do all fields have clear labels?
  • Are required fields announced as required?
  • Are error messages read out when they appear?
  • Does the error summary work properly?

Visual Testing

Check that your form is visually clear:

  • Do error states stand out visually (not just with color)?
  • Is there enough contrast between text and background?
  • Are required fields clearly marked?
  • Is the form layout clear and consistent?

Regular testing with real users, especially those who use assistive technologies, will help you find and fix issues before they affect your visitors.

Building Accessible Forms | A Step-by-Step Approach


Let’s put everything together into a step-by-step process for creating accessible forms:

  1. Start with proper HTML structure
    1. Use semantic elements like <form>, <fieldset>, and <legend>
    1. Group related fields together
    1. Follow a logical tab order
  2. Add clear labels and instructions
    1. Connect labels to fields using for attributes
    1. Mark required fields clearly in the label text
    1. Provide help text for complex fields
  3. Implement proper validation
    1. Validate when the user submits the form, not while typing
    1. Use both client-side and server-side validation
    1. Connect error messages to their fields
  4. Create helpful error recovery
    1. Show a summary for multiple errors
    1. Use ARIA live regions for dynamic updates
    1. Maintain user input after submission errors
  5. Test with real assistive technologies
    1. Check keyboard navigation
    1. Test with screen readers
    1. Ensure all states and errors are properly announced

Following these steps will help you create forms that work well for all users, including people with disabilities..

Promotional thumbnail for 'ROI of Digital Accessibility Investments in Business Growth' with a purple background. Features a YouTube subscribe button, the accessibility-test.org logo with tagline 'COMPARE. CHECK. COMPLY.', and an illustration showing business growth charts, money symbols, and cartoon figures analyzing financial data, indicating the financial benefits of accessibility investments.

Automated testing tools provide a fast way to identify many common accessibility issues. They can quickly scan your website and point out problems that might be difficult for people with disabilities to overcome.


Banner comparing top accessibility tools with headline 'Compare the Best Accessibility Tools | Updated Weekly'. Shows three recommended tools with ratings: UserWay (8/10) for AI-powered WCAG compliance, AccessiBe (7/10) for automated ADA compliance, and AudioEye (9.5/10, labeled 'Best Overall') offering hybrid solution with automation and expert audits. Last updated February 15, 2025. The page helps users compare features, pricing and benefits for WCAG, ADA, and Section 508 compliance.

Run a FREE scan to check compliance and get recommendations to reduce risks of lawsuits


Webpage interface with the heading 'Is your website Accessible & Compliant?' featuring a shield logo, a URL input field, country compliance options, and a 'Start Accessibility Scan' button.

Creating accessible forms isn’t just about following rules—it’s about making sure everyone can use your website. By paying attention to details like proper labels, clear error messages, and helpful validation, you build forms that work better for everyone.

Remember these key points:

  • Connect labels properly to form fields
  • Tell users clearly which fields they must fill in
  • Check form information when users submit, not while they’re typing
  • Show helpful error messages that explain how to fix problems
  • Keep users’ information when they need to fix mistakes
  • Use ARIA to make sure screen readers announce important updates

By applying these practices, you’ll create forms that more people can use successfully, leading to better outcomes for both your users and your website goals.

Run a FREE scan to check compliance and get recommendations to reduce risks of lawsuits.