Linking Form Errors to the Fields They Describe

A server-side rejection can identify each affected field so people and interfaces know which input needs correction.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace two problems
  2. Retain error context
  3. Let a reader locate the field from the error text
  4. Test with keyboard and an accessible inspection tool

Trace two problems

A form can report a missing title and a quantity of zero when both violate independent rules. Attach the first to title and the second to quantity. Structured results keep codes separate from text.

Retain error context

A general summary may link readers to individual fields. Inline text can explain how to repair the problem. Test keyboard traversal after submission. Preserving user input after an error keeps valid values available.[1][2]

Let a reader locate the field from the error text

A form can report that the end date must follow the start date. Connect the inline message to the affected control and provide a summary when several errors prevent submission. A visual border alone gives too little information to identify or understand the problem. See server-side field validation.

Summary links to end-date control
Control has a consistent visible label
Message describes the relationship and is associated with the control

Test with keyboard and an accessible inspection tool

Verify focus moves predictably following a failed submission, if the interface implements focus handling. Check that a person can locate the field without relying on color and that an unrelated field does not inherit the wrong message.

References

  1. IETF, RFC 9110: HTTP Semantics ↩
  2. WHATWG, HTML Living Standard: Forms ↩