-
Notifications
You must be signed in to change notification settings - Fork 382
Expand file tree
/
Copy pathindex.html
More file actions
92 lines (88 loc) · 2.34 KB
/
index.html
File metadata and controls
92 lines (88 loc) · 2.34 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Using ARIA live regions or role=alert to identify errors: WCAG 2</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body{
background:#fff;
color:#000;
font:100% / 1.5 sans-serif;
}
input{
border:1px solid #000;
font:inherit;
}
[type=submit]{
background: #666;
color:#fff;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(e) {
$('#signup').submit(function() {
$('#errors').html('');
if ($('#first').val() === '') {
$('#errors').append('<p>Please enter your first name.</p>');
}
if ($('#last').val() === '') {
$('#errors').append('<p>Please enter your last name.</p>');
}
if ($('#email').val() === '') {
$('#errors').append('<p>Please enter your email address.</p>');
}
return false;
});
$('#signup2').submit(function() {
$('#errors2').html('');
if ($('#first2').val() === '') {
$('#errors2').append('<p>Please enter your first name.</p>');
}
if ($('#last2').val() === '') {
$('#errors2').append('<p>Please enter your last name.</p>');
}
if ($('#email2').val() === '') {
$('#errors2').append('<p>Please enter your email address.</p>');
}
return false;
});
$('#signup3').submit(function() {
$('#errors3').html('');
if ($('#first3').val() === '') {
$('#errors3').append('<p>Please enter your first name.</p>');
}
if ($('#last3').val() === '') {
$('#errors3').append('<p>Please enter your last name.</p>');
}
if ($('#email3').val() === '') {
$('#errors3').append('<p>Please enter your email address.</p>');
}
return false;
});
});
</script>
</head>
<body>
<h1>Using ARIA live regions or <code>role=alert</code> to identify errors</h1>
<form name="signup" id="signup" method="post" action="">
<p id="errors" role="alert" aria-atomic="true"></p>
<p>
<label for="first">First Name (required)</label><br>
<input type="text" name="first" id="first">
</p>
<p>
<label for="last">Last Name (required)</label><br>
<input type="text" name="last" id="last">
</p>
<p>
<label for="email">Email (required)</label><br>
<input type="text" name="email" id="email">
</p>
<p>
<input type="submit" name="button" id="button" value="Submit">
</p>
</form>
</body>
</html>