Skip to content

Commit 109185c

Browse files
committed
Add autocomplete attributes
1 parent 8feea09 commit 109185c

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

techniques/general/G211.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,16 @@ <h3>Stacked Labels</h3>
106106
<p>Figure 4 shows a variation on stacked labels, where hints and guidance are included between the label and the input. This design does not provide an adjacent label. However, the "New Password" label is still considered to be in close enough proximity, especially given its size and boldness relative to the smaller and lower-contrast guidance text. The associations are reinforced programmatically, where the hint text is given a role of <code class="language-html">aria-describedby</code> and the label is properly associated with the input.</p>
107107
<figure id="figure-new-password">
108108
<img src="img/new-password.png" alt="New Password. Passwords must be 10 or more characters, and contain at least one capital, numeric and non-alphanumeric.'">
109-
<figcaption>Figure 4 New Password label positioned above input with a smaller-point text string about the password requirements positioned between the large label and the input.</figcaption>
109+
<figcaption>Figure 4 "New password" label positioned above input with a smaller-point text string about the password requirements positioned between the large label and the input.</figcaption>
110110
</figure>
111111
<p>The hint text in such implementations should be kept to a single line where possible, since accessibility issues can arise where a more lengthy hint separates the label from its input. Figure 4 illustrates that the concept of "adjacent text" is a guide for label interpretation, but cannot always serve as a hard rule.</p>
112112
<pre><code class="language-html">&lt;form&gt;
113-
&lt;label class="label" for="example-2"&gt;Password&lt;/label&gt;
113+
&lt;label class="label" for="example-2"&gt;New password&lt;/label&gt;
114114
&lt;span id="example-2-hint" class="hint"&gt;
115115
Passwords must be 10 or more characters, and contain at least one capital, numeric and non-alphanumeric.
116116
&lt;/span&gt;
117-
&lt;input class="input" id="example-2" name="example-2" type="text" aria-describedby="example-2-hint"&gt;
117+
&lt;input class="input" id="example-2" name="example-2" type="password"
118+
autocomplete="new-password" aria-describedby="example-2-hint"&gt;
118119
&lt;/form&gt;</code></pre>
119120
<p class="working-example"><a href="../../working-examples/label-in-name-general/example2.html">Working example of stacked labels</a></p>
120121

@@ -151,9 +152,9 @@ <h3>Text in parentheses and punctuation</h3>
151152
<figcaption>Figure 6 The "Name" and "Birth date" labels with additional information (and asterisk and an input formatting instruction, respectively)</figcaption>
152153
</figure>
153154
<pre><code class="language-html">&lt;label for="name"&gt;Name&lt;/label&gt; *
154-
&lt;input type="text" name="name" id="name" required&gt;
155+
&lt;input type="text" name="name" id="name" autocomplete="name" required&gt;
155156
&lt;label for="birth"&gt;Birth date&lt;/label&gt; (&lt;span id="mask"&gt;YYYY-MM-DD&lt;/span&gt;)
156-
&lt;input type="text" name="birth" id="birth" aria-describedby="mask"&gt;</code></pre>
157+
&lt;input type="text" name="birth" id="birth" autocomplete="bday" aria-describedby="mask"&gt;</code></pre>
157158

158159
<p class="working-example"><a href="../../working-examples/label-in-name-general/example3.html">Working example of inputs with simplified accessible names</a></p>
159160

working-examples/label-in-name-general/example2.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@
5454

5555
<div class="form-group">
5656
<label class="label" for="example-2">
57-
Password
57+
New password
5858
</label>
5959
<span id="example-2-hint" class="hint">
6060
Must be 10 or more characters, and contain at least one capital, numeric and non-alphanumeric.
6161
</span>
62-
<input class="input" id="example-2" name="example-2" type="text" aria-describedby="example-2-hint">
62+
<input class="input" id="example-2" name="example-2" type="password" autocomplete="new-password" aria-describedby="example-2-hint">
6363
</div>
6464
</form>
6565
</body>

working-examples/label-in-name-general/example3.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</head>
2525
<body>
2626
<label for="name">Name</label> *
27-
<input type="text" name="name" id="name" required>
27+
<input type="text" name="name" id="name" autocomplete="name" required>
2828
<label for="birth">Birth date</label> (<span id="mask">YYYY-MM-DD</span>)
29-
<input type="text" name="birth" id="birth" aria-describedby="mask">
29+
<input type="text" name="birth" id="birth" autocomplete="bday" aria-describedby="mask">
3030
</body>
3131
</html>

0 commit comments

Comments
 (0)