-
Notifications
You must be signed in to change notification settings - Fork 0
/
aria_live_test.html
65 lines (64 loc) · 2.58 KB
/
aria_live_test.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
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#wrapper {
margin-left: auto;
margin-right: auto;
width: 50%;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
<script language="javascript">
function passwordChanged() {
var strength = document.getElementById('strength');
var strongRegex = new RegExp("^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$");
var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$");
var enoughRegex = new RegExp("(?=.{8,}).*");
var pwd = document.getElementById("password");
if (pwd.value.length == 0) {
strength.innerHTML = 'Please enter a password';
} else if (false == enoughRegex.test(pwd.value)) {
strength.innerHTML = 'More Characters';
} else if (strongRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:green">The password you entered is strong!</span>';
} else if (mediumRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:#EA760F">The password you entered is Medium!</span>';
} else {
strength.innerHTML = '<span style="color:red">The password you entered is Weak!</span>';
}
}
</script>
</head>
<body>
<div id="wrapper">
<div class="center">
<h1>ARIA Live Testing</h1>
</div>
<p>Test of ARIA Live support. To test, navigate to the Password field and enter text.</p>
<p>To generate live messages:
<ul>
<li><strong>More characters</strong> – If the length is under 8 characters.</li>
<li><strong>Weak</strong> – If the length is less than 10 characters and doesn’t contain a combination of symbols, caps, text.</li>
<li><strong>Medium</strong> – If the length is 10 characters or more and has a combination of symbols, caps, text.</li>
<li><strong>Strong</strong> – If the length is 14 characters or more and has a combination of symbols, caps, text.</li>
</ul>
</p>
<p>To test:
<ul>
<li>Start the screen reader of your choice</li>
<li>Enter text into the Password field</li>
<li>Stop typing as the strength text changes and the screen reader should announce the change due to ARIA live</li>
</ul>
</p>
<label for="password">Password:</label>
<input name="password" id="password" type="text" size="15" maxlength="100" onkeyup="return passwordChanged();" /><br />
<span id="strength" aria-live="polite">Type Password</span>
</div>
</body>
</html>