The Warta RT sign-up: press Kirim on a real form and see the browser’s validation or your script, what Mr. Sugeng hears from aria-invalid and…
Why it matters
Forms fail validation every day. When the error only comes through colour and position, a screen reader user only hears “edit text” and presses Kirim again without knowing why. Wiring aria-invalid and aria-describedby correctly is what makes a form usable by everyone (WCAG 3.3.1 Error Identification, 3.3.3 Error Suggestion).
The key idea
A red error on screen is not an error anyone hears
Common mistakes
The red error shows on screen, but the screen reader still only says “edit text” The error is visible but not wired. Put aria-describedby="email-error" on the input and id="email-error" on the error element, the same letter by letter, plus aria-invalid="true" on failure.
The screen reader shouts “invalid” although the field is actually rightaria-invalid="true" is written statically in the markup. Set it from the script on every submit: field.setAttribute('aria-invalid', String(!field.checkValidity())), so it turns back to false once the value is right.
Two “required” attributes, as if doubled for the screen reader, when only one is neededrequired and aria-required="true" are one and the same state: a screen reader says “required” once, so the second is only doubled markup (which can contradict, e.g. aria-required="false"). Use required on a real input; aria-required only for a custom widget such as <div role="textbox"> that has no built-in validation.
Try it in this playground
Send the box empty in The red error Wulan sees a red error, Mr. Sugeng only hears “Email, edit text, required, blank”. The error is not wired.
Wire it: aria-describedby="…" + the same id, switch aria-invalid on, send a wrong one Mr. Sugeng now hears “invalid” and the error message.
In A static aria-invalid, send a right email Mr. Sugeng still hears “invalid”: a static attribute does not know the value is right.
Open aria-required alone, send it empty An empty letter reaches the neighbourhood head. aria-required only says “required”; checkValidity() stays true.