Skip to main content
Logo Appt Light

Success Criterion 3.3.1 - Level A

Error Identification

Ensure a clear error message is shown when data has been entered incorrectly. It often happens that data is entered incorrectly. Clearly indicate which input is incorrect and explain why. It is important that error messages are also clear for user of assistive technologies. Ensure errors are also indicated in text to allow everyone to perceive them.

Impact

  • Filling in data correctly becomes easier for everyone when error messages are clearly indicated.

  • Clear error messages are especially important for people with cognitive, language and learning disabilities.

Check

"Are input errors indicated clearly when entering incorrect data?

This can be tested without assistive technologies.

Solution

Show errors

On Android, you can use a TextView to show an error message. The error message should also be posted to assistive technologies by using an accessibility announcement.

You can also use TextInputLayout, which makes showing error messages easier. Set setErrorEnabled to true and then set the error message by using the setError method.

textView.setVisibility(View.VISIBLE)
textView.text = "Invalid date, must be in the form DD/MM/YYYY, for example, 01/01/2000"

input.setErrorEnabled(true)
input.setError("Invalid date, must be in the form DD/MM/YYYY, for example, 01/01/2000")

Use accessibility announcements

On Android, you can post an accessibility message by using the AccessibilityManager object. Create an AccessibilityEvent, set the type to AccessibilityEvent.TYPE_ANNOUNCEMENT and supply a message.

val type = AccessibilityEventCompat.TYPE_ANNOUNCEMENT

val event = AccessibilityEvent.obtain(type)
event.text.add("Appt announcement")
event.className = Context::class.java.name
event.packageName = packageName

val accessibilityManager = ContextCompat.getSystemService(this, AccessibilityManager::class.java)
accessibilityManager?.sendAccessibilityEvent(event)

Use accessibility live region

On Android, a live region can be set by using the convience method setAccessibilityLiveRegion of ViewCompat. To interrupt ingoing speech, also known as being assertive, use ACCESSIBILITY_LIVE_REGION_ASSERTIVE. To wait for ongoing speech, also known as being polite, use ACCESSIBILITY_LIVE_REGION_POLITE.

// Interrupt ongoing speech
ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_ASSERTIVE)

// Wait for ongoing speech
ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE)

Resources

Feedback?

Let us know!