-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathonsubmit06.html
124 lines (117 loc) · 5.06 KB
/
onsubmit06.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>onSubmit error notification: focus on the heading, inside 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 the heading, inside <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.</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" role="group">
<h4 id="error" class="focus" tabindex="-1">
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">Heading level 4. Error: Please fix the following two errors and resubmit the form</span>.</li>
<li><b>Firefox:</b> <span class="green">Heading level 4. Error: Please fix the following two errors and resubmit the form</span>.</li>
<li><b>Safari:</b> <span class="green">Heading level 4. Error: Please fix the following two errors and resubmit the form</span>.</li>
</ul>
</div>
<div class="note">
<h3>NVDA: onsubmit</h3>
<ul class="browser-list">
<li><b>Chrome:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Heading level 4.</span></li>
<li><b>Firefox:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Heading level 4.</span></li>
<li><b>Edge:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Heading level 4.</span></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 Heading level 4.</span></li>
<li><b>Firefox:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Heading level 4.</span></li>
<li><b>Edge:</b> <span class="green">Error: Please fix the following two errors and resubmit the form. Heading level 4.</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("role", "group");
x.innerHTML += `
<h4 id="error" class="focus" tabindex="-1">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>