#32820: Django forms - fields’ errors should be programmatically associated with
fields
-------------------------------------+-------------------------------------
Reporter: Thibaud | Owner: nobody
Colas |
Type: Bug | Status: new
Component: Forms | Version: 3.2
Severity: Normal | Keywords: accessibility, ui,
Triage Stage: | forms
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Related: [https://code.djangoproject.com/ticket/32819 #32819]. This could
be worth fixing at the same time, although I would expect this issue
shouldn’t require as breaking of a change to fix.
Django currently displays errors above fields in its forms rendering:
{{{
<ul class="errorlist">
<li>This field is required.</li>
</ul>
<p>
<label for="id_duration_required">Duration required:</label>
<input type="text" name="duration_required" required=""
id="id_duration_required">
<span class="helptext">Help</span>
</p>
}}}
One thing this is missing is a way to programmatically indicate the field
is in error – currently this can only be inferred visually because the
error messages are displayed above the field. This is fail of WCAG 2.1
level A [https://www.w3.org/WAI/WCAG21/Understanding/error-identification
3.3.1: Error Identification]. The most common way to do this
programmatically is to use `aria-invalid="true"` on the field, as
demonstrated in the non-normative
[https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA21 technique ARIA21]:
{{{
<input type="text" name="duration_required" required=""
id="id_duration_required" aria-invalid="true">
}}}
Here is the result in VoiceOver on Safari – announcing "invalid data"
after the field label and required state:
Screenshot of the VoiceOver text-to-speech output, announcing "Email
required: required invalid data edit text"
--
Ticket URL: <https://code.djangoproject.com/ticket/32820>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/055.86094edb8ea78611f2d42bb7b32ecb87%40djangoproject.com.