-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrequired05.html
67 lines (65 loc) · 3.95 KB
/
required05.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>input with required and aria-hidden="true" applied to "(Required)" text</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico">
<link href="assets/css/examples.css" rel="stylesheet">
</head>
<body>
<h1><code><input></code> with <code>required</code> and <code>aria-hidden="true"</code> applied to "(Required)" text</h1>
<p>← <a href="index.html">Return to main list</a></p>
<p>In this case, the visual "Required" indicator is hidden from assistive technologies via the <a href="https://www.w3.org/TR/wai-aria/#aria-hidden"><code>aria-hidden</code></a> attribute. So, only the <a href="https://www.w3.org/TR/html52/sec-forms.html#the-required-attribute"><code>required</code></a> attribute should be announced, along with the <code><label></code> content</p>
<h2>Note on <code>required</code> usage</h2>
<p>If the <code>required</code> attribute is applied, the invalid state is also set in accessibility APIs. So, form controls with <code>required</code> applied are announced as "Invalid entry" or "Invalid data", even before users have interacted with the control. <a href="https://github.com/w3c/aria/issues/1488" target="_blank">More details on the issue</a>.</p>
<p>Even though native HTML attributes should be used where possible, authors could choose to use <code>aria-required="true"</code> instead. However, authors should not use <code>aria-invalid="false"</code> to solve this issue.</p>
<blockquote>
<p><i>However, if the user has not attempted to submit the form, authors SHOULD NOT set the aria-invalid attribute on required widgets simply because the user has not yet entered data.</i></p>
<p><a href="https://www.w3.org/TR/wai-aria-1.1/#aria-invalid" target="_blank">Source</a>.</p>
</blockquote>
<h2>Example</h2>
<form action="#">
<div class="form-group">
<label class="label" for="name">Full name <span class="required" aria-hidden="true">(Required)</span></label>
<input required class="input" type="text" id="name">
</div>
</form>
<h2>Code</h2>
<!-- start code -->
<pre><code><div class="form-group">
<label class="label" for="name">
Full name
<span class="required" aria-hidden="true">(Required)</span>
</label>
<input required class="input" type="text" id="name">
</div></code></pre>
<!-- end code -->
<h2>Assistive technologies</h2>
<div class="note">
<h3>VoiceOver</h3>
<ul class="browser-list">
<li><b>Chrome:</b> Full name. <span class="green">Required</span>. <span class="red">Invalid data</span>. Edit text.</li>
<li><b>Firefox:</b> Full name. <span class="green">Required</span>. <span class="red">Invalid data</span>. Edit text.</li>
<li><b>Safari:</b> Full name. <span class="green">Required</span>. Edit text.</li>
</ul>
</div>
<div class="note">
<h3>NVDA</h3>
<ul class="browser-list">
<li><b>Chrome:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Blank.</li>
<li><b>Firefox:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Has autocomplete. Blank.</li>
<li><b>Edge:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Blank.</li>
</ul>
</div>
<div class="note">
<h3>JAWS</h3>
<ul class="browser-list">
<li><b>Chrome:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Type in text.</li>
<li><b>Firefox:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Type in text.</li>
<li><b>Edge:</b> Full name. Edit. <span class="green">Required</span>. <span class="red">Invalid entry</span>. Type in text.</li>
</ul>
</div>
<p>← <a href="index.html">Return to main list</a></p>
</body>
</html>