-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathform.html
164 lines (164 loc) · 7.3 KB
/
form.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
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>An Accessible Form</title>
<link rel="stylesheet" href="css/normalization.css" />
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/form.css" />
</head>
<body>
<div class="container">
<p><a href="http://haltersweb.github.io/Accessibility/">View the library of solutions.</a></p>
<div class="page-wrapper">
<h1>Welcome to an Accessible Form</h1>
<p>To see <strong>error handling</strong> click the submit button.</p>
<p>Error messages will be tied to their offending input fields using aria-describedby and aria-invalid</p>
<p><a href="#">Fake link</a>. Voluptatem corrupti possimus sit, sequi, quo corporis ipsa, perferendis ipsum, voluptates eius maxime sint ex assumenda? At atque dolorem dolorum qui maiores.</p>
<h2>Tracking Your Eating Habits</h2>
<form action="post">
<div class="form-row">
<label for="honorific">Honorific</label>
<select name="honorific" id="honorific">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Ms.">Ms.</option>
</select>
</div>
<div class="form-row">
<label for="firstName">First Name</label>
<input id="firstName" type="text" />
</div>
<div class="form-row">
<label for="lastName" class="required-field">Last Name</label>
<input id="lastName" type="text" aria-required="true" />
</div>
<div class="form-row">
<label for="date" class="required-field">Birthday</label>
<input type="date" id="date" aria-required="true" aria-describedby="dateInstr" />
<span id="dateInstr">write in MM/DD/YYYY format</span>
</div>
<div class="form-row">
<label for="anotherName">Another Name</label>
<input id="anotherName" type="text" disabled />
</div>
<fieldset>
<legend><span class="legend">What is your favorite time to eat? (example with nested label/input)</span></legend>
<div class="form-row">
<label for="morning" class="inline-label">
<input type="radio" name="eating_times" id="morning" />
morning
</label>
<label for="afternoon" class="inline-label">
<input type="radio" name="eating_times" id="afternoon" />
afternoon
</label>
<label for="evening" class="inline-label">
<input type="radio" name="eating_times" id="evening" />
evening
</label>
</div>
</fieldset>
<fieldset>
<legend><span class="legend">What are your favorite foods? (examples with sequential label/input)</span></legend>
<fieldset>
<legend><span class="legend">Favorite Fruits</span></legend>
<div class="form-row">
<input type="checkbox" id="apples" name="fruits" />
<label for="apples">apples</label>
</div>
<div class="form-row">
<input type="checkbox" id="oranges" name="fruits" />
<label for="oranges">oranges</label>
</div>
</fieldset>
<fieldset>
<legend><span class="legend">Favorite Vegetables</span></legend>
<div class="form-row">
<input type="checkbox" id="lettuce" name="vegetables" />
<label for="lettuce">lettuce</label>
</div>
<div class="form-row">
<input type="checkbox"id="carrots" name="vegetables" />
<label for="carrots">carrots</label>
</div>
</fieldset>
</fieldset>
<div style="border: 1px dotted gray; padding: 10px; background-color: #eee;">
<h3>Custom Radio And Checkboxes</h3>
<p>To make image replacement work I have:</p>
<ul class="bullet singletons">
<li>Used SVGs so that they will still show up in high contrast mode.</li>
<li>Nested the input and SVGs within their labels.</li>
<li>Added the SVGs as next siblings of their input fields.</li>
<li>Positioned the actual input fields behind their SVGs.</li>
<li>Made sure SVG focusable="false" and role="presentation".</li>
<li>Insured that focus is shown on the SVG when the input has focus.</li>
</ul>
<fieldset class="img-replacement">
<legend><span class="legend">What is your favorite place to eat? (example with image replacement)</span></legend>
<div class="form-row">
<label for="home" class="inline-label">
<input type="radio" name="eating_place" id="home" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" role="presentation" focusable="false" class="svg-radio">
<circle class="stroke" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="12.5" cy="12.5" r="11.5"/>
<circle class="center" cx="12.5" cy="12.5" r="6.5"/>
</svg>
home
</label>
<label for="restaurant" class="inline-label">
<input type="radio" name="eating_place" id="restaurant" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 25" role="presentation" focusable="false" class="svg-radio">
<circle class="stroke" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="12.5" cy="12.5" r="11.5"/>
<circle class="center" cx="12.5" cy="12.5" r="6.5"/>
</svg>
restaurant
</label>
</div>
</fieldset>
<fieldset class="img-replacement">
<legend><span class="legend">What do you have for breakfast?</span></legend>
<div class="form-row">
<label for="oatmeal">
<input type="checkbox" id="oatmeal" name="breakfast" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29" role="presentation" focusable="false" class="svg-checkbox">
<rect class="stroke" x="3" y="3" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" width="23" height="23"/>
<polygon class="center" fill="#000000" points="13,13 4,5 3,5 3,6 12,23 14,23 29,1 29,0 28,0"/>
</svg>
oatmeal
</label>
</div>
<div class="form-row">
<label for="eggs">
<input type="checkbox"id="eggs" name="breakfast" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29" role="presentation" focusable="false" class="svg-checkbox">
<rect class="stroke" x="3" y="3" fill="#FFFFFF" stroke="#000000" stroke-width="2" stroke-miterlimit="10" width="23" height="23"/>
<polygon class="center" fill="#000000" points="13,13 4,5 3,5 3,6 12,23 14,23 29,1 29,0 28,0"/>
</svg>
eggs
</label>
</div>
</fieldset>
</div>
<div class="form-row">
<label for="about" class="legend block-label">Tell Us About Yourself</label>
<textarea name="about" id="about" cols="30" rows="10"></textarea>
</div>
<div class="form-row">
<button type="button" class="btn-secondary" disabled>Do Something</button>
<button type="reset" class="btn-secondary">Reset</button>
<button type="submit" class="btn-primary">Submit</button>
</div>
</form>
<p>Lorem ipsum dolor sit amet, <a href="#">consectetur adipisicing elit</a>. Voluptatem corrupti possimus sit, sequi, quo corporis ipsa, perferendis ipsum, voluptates eius maxime sint ex assumenda? At atque dolorem dolorum qui maiores.</p>
</div>
<div class="overlay"></div>
<div class="block-screen"></div>
</div>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/namespacing.js"></script>
<script type="text/javascript" src="js/accessibility-helpers.js"></script>
<script type="text/javascript" src="js/form.js"></script>
</body>
</html>