Marlon
Marlon

Reputation: 1877

How to set a different message for a Asp.net Validator for a screen reader

I'm creating a Asp.net MVC Site, and i'd like to have the message "Required" to show bellow required input fields (Not "The Field 'Name' is Required", since the message is already bellow the right field) if the user didn't fill a value. I achieved that with a custom RequiredAttribute .

Now I'm worried about someone using a screen reader. If someone is blind and is using a screen reader to read the page, it will read "Required" for this text, but since he is not able to seee the controls, it would be better if it shows "The Field "Name" is Required".

Is there a way to show a specific text in the screen, but provide another for a screen reader?

Upvotes: 0

Views: 31

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239290

No, it's not possible, mostly because there's no way to reliably detect if a screen reader is being used. You might, and I stress might be able to inspect the User-Agent string, but that assumes that every screen reader would use a custom UA string that identifies itself as such, and that you account for all of the possible variations of those. In short, that would lead to very brittle design, if it worked at all.

I think you're looking at the issue wrong, though. Accessibility is not just about obvious disabilities such as blindness. There's people who just have poor vision, in general, but wouldn't necessarily be using a screen reader, people with learning or other cognitive disabilities, etc. The goal should always be obvious design. Does it hurt to show the entire text "The field 'Foo' is required." or would it otherwise cause any problems for non-impaired users? The answer is: no. It may be overly-verbose, but it's not problematic to show the full text. On the other hand, would hiding part of the text put additional stress on impaired users? The answer is: it might. Therefore, it's better to show the full text always.

Upvotes: 1

Related Questions