-
Notifications
You must be signed in to change notification settings - Fork 1
/
aria-alert-validation.html
73 lines (72 loc) · 2.01 KB
/
aria-alert-validation.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Using role=alert to Identify Errors</title>
<script src="http://code.jquery.com/jquery.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 role=alert to Identify Errors</h1>
<form name="signup" id="signup" method="post" action="">
<p id="errors" role="alert" aria-live="assertive" 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>