-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathonsubmit03.html
160 lines (153 loc) · 6.14 KB
/
onsubmit03.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>onSubmit error notification: focus on a container with role="group"</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>onSubmit error notification: focus on a container with <code>role="group"</code></h1>
<p>← <a href="index.html">Return to main list</a></p>
<p>This is a test case designed to determine whether assistive technologies announce an error message injected above a form - with the addition of <a href="https://www.w3.org/TR/wai-aria-1.1/#group" target="_blank"><code>role="group"</code></a>.</p>
<h2>Example</h2>
<div class="example">
<h3 class="contact-details-heading">Contact details</h3>
<div id="error-notification-container">
</div>
<form action="#" class="unstyled">
<div class="form-container">
<label class="label" for="name">Name</label>
<input class="input" type="text" id="name">
<span id="name-error-container"></span>
</div>
<div class="form-container">
<label class="label" for="address">Address</label>
<input class="input" type="text" id="address">
</div>
<div class="form-container">
<label class="label" for="email">Email</label>
<input class="input" type="email" id="email">
<span id="email-error-container"></span>
</div>
</form>
<button class="button" onclick="addError()">Submit</button>
</div>
<h2>Code</h2>
<!-- start code -->
<pre><code><div
class="error-notification"
tabindex="-1"
id="error"
role="group"
aria-labelledby="f1-label"
>
<h4 id="f1-label">
Error: Please fix the following two errors and...
</h4>
<ul>
<li><a href="#name">Name: You must include a name</a></li>
<li><a href="#email">Email: You must use a valid...</a></li>
</ul>
</div></code></pre>
<!-- end code -->
<h2>Assistive technologies</h2>
<div class="note">
<h3>VoiceOver: onsubmit</h3>
<ul class="browser-list">
<li><b>Chrome:</b> <span class="green">Error: Please fix the following two errors and resubmit the form</span>. <span class="green">Group</span>.</li>
<li><b>Firefox:</b> <span class="green">Error: Please fix the following two errors and resubmit the form</span>. <span class="green">Group</span>.</li>
<li><b>Safari:</b> <span class="green">Error: Please fix the following two errors and resubmit the form</span>. <span class="green">Group</span>.</li>
</ul>
</div>
<div class="note">
<h3>NVDA: onsubmit</h3>
<ul class="browser-list">
<li><b>Chrome:</b>
<ul>
<li>Error: Please fix the following two errors and resubmit the form.</li>
<li>Grouping.</li>
<li>Error: Please fix the following two errors and resubmit the form. Heading level 4.</li>
<li>List.</li>
<li>Name: You must include a name. Link.</li>
<li>Email: You must use a valid email address.</li>
</ul>
</li>
<li><b>Firefox:</b>
<ul>
<li>Error: Please fix the following two errors and resubmit the form.</li>
<li>Grouping.</li>
<li>Error: Please fix the following two errors and resubmit the form. Heading level 4.</li>
<li>List.</li>
<li>Name: You must include a name. Link.</li>
<li>Email: You must use a valid email address.</li>
</ul>
</li>
<li><b>Edge:</b>
<ul>
<li>Error: Please fix the following two errors and resubmit the form.</li>
<li>Grouping.</li>
<li>Error: Please fix the following two errors and resubmit the form. Heading level 4.</li>
<li>List.</li>
<li>Name: You must include a name. Link.</li>
<li>Email: You must use a valid email address.</li>
</ul>
</li>
</ul>
</div>
<div class="note">
<h3>JAWS: onsubmit</h3>
<ul class="browser-list">
<li><b>Chrome:</b> <span class="green">Error: Please fix the following two errors and resubmit the form</span>.</li>
<li><b>Firefox:</b> <span class="green">Error: Please fix the following two errors and resubmit the form</span>.</li>
<li><b>Edge:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Group.</span></li>
</ul>
</div>
<p>← <a href="index.html">Return to main list</a></p>
<script>
function addError() {
if(document.getElementById("error") != null){
} else {
var x = document.createElement("div");
x.setAttribute("class", "error-notification");
x.setAttribute("tabindex", "-1");
x.setAttribute("id", "error");
x.setAttribute("role", "group");
x.setAttribute("aria-labelledby", "f1-label");
x.innerHTML += `
<h4 id="f1-label">Error: Please fix the following two errors and resubmit the form</h4>
<ul>
<li><a href="#name">Name: You must include a name</a></li>
<li><a href="#email">Email: You must use a valid email address</a></li>
</ul>
`;
document.getElementById("error-notification-container").appendChild(x);
document.getElementById("error").focus();
}
var t = document.getElementById("name");
t.setAttribute("aria-describedby", "name-error");
t.setAttribute("aria-invalid", "true");
if(document.getElementById("name-error") != null){
} else {
var y = document.createElement("span");
y.setAttribute("class", "error-message");
y.setAttribute("id", "name-error");
y.innerHTML += `You must include a name`;
document.getElementById("name-error-container").appendChild(y);
}
var q = document.getElementById("email");
q.setAttribute("aria-describedby", "email-error");
q.setAttribute("aria-invalid", "true");
if(document.getElementById("email-error") != null){
} else {
var z = document.createElement("span");
z.setAttribute("class", "error-message");
z.setAttribute("id", "email-error");
z.innerHTML += `You must use a valid email address`;
document.getElementById("email-error-container").appendChild(z);
}
}
</script>
</body>
</html>