You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validation is easy to begin with (<input type="text" required>) and very difficult to master (accessibility, complex patterns, dependency on other fields, custom business logic, async validation on the server).
Here's a proposal that explores validation components that take some of the burden (especially accessibility and display style) from the user.
After submit, the first invalid field needs to receive focus
Error messages should be announced through aria-live=polite (especially if validation happens without page reload)
[optional] Validation messages can be displayed grouped together at the start of the form in addition to being displayed below the element (example with grouped error messages)
A single error message should be presented as text, a list of messages should be presented as a list
Suggested pattern
<form><!-- Optional feedback summary at the beginning of the form --><post-feedback-summarytype="invalid"></post-feedback-summary><!-- Invalid feedback with one item --><inputtype="text" name="name" id="name"><post-feedbacktype="invalid" for="name"><post-feedback-item>Please enter a valid name.</post-feedback-item></post-feedback><!-- Invalid feedback with multiple itmes, should be rendered with role="list" and role="listitem" --><inputtype="text" name="password" id="password"><post-feedbacktype="invalid" for="password"><post-feedback-item>The password field is required.</post-feedback-item><post-feedback-item>Please enter a password with more than 18 characters.</post-feedback-item></post-feedback></form>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Validation is easy to begin with (
<input type="text" required>
) and very difficult to master (accessibility, complex patterns, dependency on other fields, custom business logic, async validation on the server).Here's a proposal that explores validation components that take some of the burden (especially accessibility and display style) from the user.
Resources
Requirements
<fieldset>
they belong to viaaria-describedby
(example with correctly connected error messages)aria-live=polite
(especially if validation happens without page reload)Suggested pattern
Beta Was this translation helpful? Give feedback.
All reactions