Drupal renders validation error text but does not always programmatically associate it with the control that failed. The proposal gives the rendered error a stable ID and points the control at it with aria-describedby, preserving help text. The same form is shown four ways.

The association in HTML

No association: the error has an ID, but the control does not reference it.

<input type="text" id="edit-name" aria-invalid="true">
<p class="error-message" id="edit-name--error-message">Name field is required.</p>

The proposed association, with the help text preserved:

<input type="text" id="edit-name" aria-invalid="true"
  aria-describedby="edit-name--error-message edit-name--description">
<p class="description" id="edit-name--description">We use this name on your profile.</p>
<p class="error-message" id="edit-name--error-message">Name field is required.</p>

A group uses the fieldset, not the options:

<fieldset aria-describedby="edit-colour--error-message edit-colour--description">
  <legend>Favourite colour</legend>
  <p class="description" id="edit-colour--description">Choose one.</p>
  <label><input type="radio" name="colour" value="red"> Red</label>
  …
  <p class="error-message" id="edit-colour--error-message">Favourite colour field is required.</p>
</fieldset>

What the association adds

No association
  textbox "Name"
  description: "We use this name on your profile."     (help only)

aria-describedby
  textbox "Name"
  description: "Name field is required. We use this name on your profile."

Group error
  group "Favourite colour"
  description: "Favourite colour field is required. Choose one."

The error is first in the description so it is heard before the help. Existing description tokens are kept.

Test it with a screen reader

VoiceOver on macOS

  1. Open No association and Tab to each field. You hear the label and, for Name, the help text; the visible error is not part of the description.
  2. Open aria-describedby and Tab again. Name should now speak the error and then the help; the radio group should speak the group error and help.
  3. Compare with aria-errormessage. Depending on the screen reader, the error may only be available in browse mode; the help text remains the focus description.

NVDA on Windows

  1. Open No association and Tab to the fields. The error text is not in the description.
  2. Open aria-describedby and Tab. The error and help should be announced with the field; NVDA+Tab or reading on reaches the visible error text too.
  3. Open Group error and Tab into the radio group. The group error and help should be announced; the individual options do not repeat them.

This page does not simulate speech. Automated checks and DOM assertions do not prove what a screen reader announces; the Lab's real VoiceOver evidence for the message landmark is on a different issue.

What this demonstration is not

Source and evidence