Skip to content

Commit 5da0caa

Browse files
committed
Provide help docs
1 parent d8d5b30 commit 5da0caa

10 files changed

+240
-28
lines changed
15.9 KB
Loading
15.9 KB
Loading
17.9 KB
Loading

docs/topics/forms/help.md

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Autocomplete
3+
layout: default
4+
parent: Provide help
5+
nav_order: 3
6+
has_video: true
7+
---
8+
9+
# Autocomplete in a form
10+
11+
The HTML [autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/autocomplete) attribute tells the browser what type of value is expected when filling in out form field. Browsers store what users have entered before. Browsers can then use those saved values to automatically fill out fields.
12+
13+
Data such as names, addresses, and phone numbers can then be filled in automatically by the browser.
14+
15+
Autocomplete is helpful for users who have difficulty typing, have memory issues, struggle with language or just love the convenience of not typing the same data over and over again.
16+
17+
## Use autocomplete when a value is defined
18+
19+
WCAG contains a complete [list of values for autocomplete](https://www.w3.org/TR/WCAG22/#input-purposes). Always use an `autocomplete` attribute if a value for a form field is defined in this list.
20+
21+
When using `autocomplete`, it is important that the label always remains visible. The user needs to know whether the correct value has been entered in the according field.
22+
23+
{: .callout .tip }
24+
**Tip**: The autocomplete value for City is `address-level2`.
25+
26+
## Code example
27+
28+
```html
29+
<input
30+
id="firstname"
31+
name="firstname"
32+
type="text"
33+
autocomplete="given-name"
34+
/>
35+
```
36+
37+
{: .callout .info }
38+
Note: `aria-autocomplete` has a different purpose and usage than autocomplete on form fields. [aria-autocomplete is used in web components](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete), for example to indicate that suggestions are available for search results.
39+
40+
## Pre-fill known information where possible
41+
42+
This doesn't address 'autocomplete', but it is related: if the user is logged in, use known information to pre-fill fields. For example, if a session already contains available information that could be used to pre-fill fields. Like a shipping address for an online order.
43+
44+
## Resources
45+
46+
### WCAG Success Criteria
47+
48+
Using the correct autocomplete attribute is required to meet WCAG Success Criterion [1.3.5 Identify Input Purpose](https://www.w3.org/WAI/WCAG22/quickref/#identify-input-purpose) (Level AA).
49+
50+
### Autocomplete in WP Plugins
51+
- Gravity Forms
52+
- WP Forms
53+
- etc
54+
55+
### Other resources
56+
57+
Jules Ernst from 200 OK has created a [Dutch interpretation of autocomplete](https://www.200ok.nl/tips/autocomplete/) of this list.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Avoid input patterns
3+
layout: default
4+
parent: Provide help
5+
nav_order: 3
6+
has_video: true
7+
---
8+
9+
# Avoid input patterns on form fields
10+
11+
Make it as easy as possible for users to enter a value flexibly. A fixed input pattern (mask) may not be suitable for the answer a user wants to provide.
12+
13+
## What is the issue about input patterns?
14+
15+
When you force a user to enter data according to a fixed pattern it can cause confusion when their value to enter doesn't match the pattern.
16+
17+
A fixed pattern can even become a barrier to completing a form.
18+
19+
For example:
20+
21+
- The phone number does not match the required pattern: the user wants to enter a foreign number, but that is not allowed.
22+
- The user wants to add important information such as “call only in the afternoon,” but cannot.
23+
- The user doesn't understand what is going wrong because, for example, letters cannot be entered and there is no good feedback explaining the error.
24+
- Screen reader users may miss the visual information about how to fill out the form.
25+
26+
Note: There are situations where an exact input is required. In those cases, always clearly explain in the description how the field should be filled in.
27+
28+
## What is a pattern on an input field?
29+
30+
A pattern (mask) defines exactly how a form field must be filled out and doesn't allow any other input.
31+
32+
This can be done using the HTML pattern attribute in combination with JavaScript.
33+
34+
The pattern specifies what the value must look like exactly. JavaScript then checks that value, may adjust the layout, and blocks invalid input. How the user is expected to enter the value according to the desired pattern is then explained in the description or in a placeholder.
35+
36+
You can restrict a first-name input field to, for example, a minimum of 3 and a maximum of 12 characters. Too bad if your name is Jo or Claus-Casimir.
37+
38+
```html
39+
<!-- Incorrect code, do not use -->
40+
<input
41+
id="firstname"
42+
name="firstname"
43+
type="text"
44+
pattern="\w{3,16}"
45+
autocomplete="given-name"
46+
/>
47+
```
48+
49+
You can require a specific format for a phone number input field. Too bad if you no longer have a landline or want to provide an international number.
50+
51+
```html
52+
<!-- Incorrect code, do not use -->
53+
<input
54+
type="tel"
55+
id="telephone"
56+
name="telephone"
57+
pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"
58+
placeholder="___-___-____"
59+
autocomplete="tel"
60+
/>
61+
```
62+
63+
## User experience and accessibility of input patterns
64+
65+
Adam Silver summarizes it well in his article [The problem with input masks and what to do instead](https://adamsilver.io/blog/the-problem-with-input-masks-and-what-to-do-instead/).
66+
67+
- The pattern may not be suitable for the answer the user wants to give.
68+
- Enforced patterns are confusing: the cursor automatically jumps to the next position, and special characters such as -, (, or ) cannot be removed.
69+
- A placeholder with an example can look like a pre-filled field.
70+
- The placeholder with the example disappears while typing, and you no longer know how to complete the rest of the value.
71+
- Because characters are removed or skipped, it can feel like something is going wrong without an immediate error message appearing.
72+
73+
In the article [Accessible input masking](https://giovanicamara.com/blog/accessible-input-masking/), Giovani Camara shows in the YouTube video [Allow users to edit anywhere](https://www.youtube.com/watch?v=rTk3XNSXJXY) what can go wrong when a user wants to change a value. The cursor can automatically jump to the end of the value while you want to edit the first character. This is annoying for everyone and leads to errors.
74+
75+
Indicating input patterns in a placeholder or in the value attribute can be very unclear for screen reader users. A series of underscores is not very informative. Watch and listen to Giovani Camara’s demo on YouTube using VoiceOver.
76+
<video data-able-player data-youtube-nocookie="true" data-youtube-id="7WWQXGgRDLc" data-heading-level="0"></video>
77+
78+
If exact input is required, for example for a date of birth, provide an option that everyone can easily complete.
79+
In addition, a [good description]({{site.baseurl}}/docs/topics/forms/help/valid-values/) and [clear error messages]({{site.baseurl}}/docs/topics/forms/feedback/error-message-text/) are important. Help the user and do not make them puzzle over how exactly to fill in a field or what went wrong again.
80+
81+
## Resources
82+
83+
### WCAG Success Criteria for descriptions
84+
85+
Providing good feedback about correctly entering data in form fields is necessary to meet the WCAG success criteria:
86+
87+
- [3.3.1 Error Identification](https://www.w3.org/WAI/WCAG22/quickref/#error-identification) (Level A)
88+
- [3.3.3 Error Suggestion](https://www.w3.org/WAI/WCAG22/quickref/#error-suggestion) (Level AA)
89+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Be flexible
3+
layout: default
4+
parent: Provide help
5+
nav_order: 3
6+
---
7+
8+
# Don’t reject a form entry too quickly
9+
10+
Be flexible accepting the data a user fills out a field. If it's not exactly in the format you want, change it for them in the code.
11+
12+
{: .info .callout}
13+
**Note**: this is best practice and not a WCAG requirement.
14+
15+
## Date formats
16+
17+
Users may unknowingly enter a different separation character then planned and then get the warning "Invalid date". While actually it's not invalid, it's not in your preferred format.
18+
19+
For example January 1, 2026 can be entered as:
20+
21+
- 01.01.2026
22+
- 01-01-2026
23+
- 01/01/2026
24+
25+
Why not help the user and transform the separation character in your software for them?
26+
27+
## Email addresses
28+
29+
Some people use a + in their email address, for example to make it easier to group emails.
30+
31+
They might use name+school@example.com for school-related emails and name+work@example.com for work emails. These are valid email addresses, so don’t reject them.
32+
33+
Email addresses with a plus sign are valid.
34+
35+
## Postal codes
36+
37+
[Postal codes](https://en.wikipedia.org/wiki/List_of_postal_codes) can be written in different ways, for example in the Netherlands as: “1234 AA” (with a space), “1234AA” (without a space), or “1234aa” (lowercase). Extra spaces at the beginning or end can also be included when text is copied and pasted.
38+
39+
In code, these variations can easily be normalized to a single format. By accepting all valid ways and letting the software correct them, you prioritize the user instead of your software.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Allow copy/paste
3+
layout: default
4+
parent: Provide help
5+
nav_order: 2
6+
---
7+
8+
# Allow copying and pasting of passwords
9+
10+
A password needs to be secure. If you prevent copying and pasting of passwords, you force users to choose simple, easy-to-remember passwords. That is exactly what you want to avoid.
11+
12+
Copying and pasting from a password manager is a much easier and safer way for users to enter a password. As explained by the UK National Cyber Security Centre in [Top tips for staying secure online](https://www.ncsc.gov.uk/collection/top-tips-for-staying-secure-online).
13+
14+
## Related WCAG Success Criteria
15+
16+
- [3.3.8 Accessible Authentication (Minimum)](https://www.w3.org/WAI/WCAG22/quickref/#accessible-authentication-minimum) Level AA (added in version 2.2)

docs/topics/forms/help/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Provide help
3+
layout: default
4+
parent: Web forms
5+
nav_order: 7
6+
description: Filling out a form should be as easy as possible. How can you best help your user?
7+
---
8+
9+
# Provide help filling out a form
10+
11+
Filling out a form should be as easy as possible. How can you best help your user?
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: Provide valid values
3+
layout: default
4+
parent: Provide help
5+
nav_order: 4
6+
---
7+
8+
# Provide valid values for a form field
9+
10+
Provide valid values for an input field (for example, date or password requirements) in the description and not only in the placeholder.
11+
12+
Also consider whether it is really important that, for example, a date of birth or phone number must meet exact input requirements.
13+
14+
![Password requirements are shown in the description.](/assets/images/richtlijnen_formulier_voorkom-fouten_wachtwoord-english.png)
15+
16+
![Examples of valid values for date of birth are shown in the description.](/assets/images/richtlijnen_formulier_voorkom-fouten_geboortedatum-english.png)
17+
18+
19+
## Resources
20+
21+
### Related WCAG Success Criteria
22+
- Helping users to understand better what they need to fill out is necessary to meet the WCAG success criterion [3.3.2 Labels or Instructions](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions) (Level AA).
23+
24+
### Related info in this documentation
25+
26+
- [Placeholders]({{site.baseurl}}/docs/topics/forms/input-label/placeholders/)
27+
- [Input field and description]({{site.baseurl}}/docs/topics/forms/descriptions/)
28+
- [Description with a fieldset]({{site.baseurl}}/docs/topics/forms/fieldsets/fieldset-descriptions/)

0 commit comments

Comments
 (0)