Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/html-form-validation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/mark-non-required-form-fields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/mark-required-form-fields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/topics/content/links/link-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Link text should stand on its own. Some assistive software scans a page for link
It also makes your text easier to scan visually, so that sighted users can more quickly find the information they’re looking for.

<figure>
<img src="/assets/images/vo-rotor-links.png" alt="">
<img src="{{site.baseurl}}/assets/images/vo-rotor-links.png" alt="">
<figcaption>Descriptive, meaningful link text in the Apple VoiceOver link list.</figcaption>
</figure>

Expand All @@ -31,7 +31,7 @@ Avoid meaningless link text like: click here, download, info, more, here, this.
With these types of links, users have to read the whole sentence to understand the purpose of the link. This makes your content less browsable, and harder to engage with. Screen reader users cannot navigate by links, because those links are not useful without additional context.

<figure>
<img src="/assets/images/incorrect-links.png" alt="">
<img src="{{site.baseurl}}/assets/images/incorrect-links.png" alt="">
<figcaption>Useless, non-descriptive link text in the Apple VoiceOver link list.</figcaption>
</figure>

Expand Down
2 changes: 1 addition & 1 deletion docs/topics/forms/descriptions/content-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In this [demo video](https://www.youtube.com/watch?v=6brKmJfDtNQ), VoiceOver in

What are the options for adding information and explanations to a form and its input fields? Follow the [description decision tree]({{site.baseurl}}/docs/topics/forms/descriptions/).

## Related WCAG Succes Criteria
## Related WCAG Success Criteria

- [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/quickref/#info-and-relationships).
- [3.3.2 Labels or Instructions](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Rich text in this context means: additional structure or interactive functionali
**Yes**: Consider a multistep form, where the information is placed directly above the form for each step.
**No**: Rewrite the description so that it only contains plain text. This ensures that all users can read the information.

## Related WCAG Succes Criteria
## Related WCAG Success Criteria

- [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/quickref/#info-and-relationships).
- [3.3.2 Labels or Instructions](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions).
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/forms/descriptions/location-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Use the "Form Layout" settings on the Form Settings screen:
- Sub-Label Placement: Above inputs

<figure>
<img src="/assets/images/form-settings-page-layout-gravity-forms.png" alt="">
<img src="{{site.baseurl}}/assets/images/form-settings-page-layout-gravity-forms.png" alt="">
<figcaption>Screenshot Form Settings in Gravity Forms version 2.9.20 .</figcaption>
</figure>

Expand Down
12 changes: 0 additions & 12 deletions docs/topics/forms/required.md

This file was deleted.

20 changes: 20 additions & 0 deletions docs/topics/forms/required/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Required fields
layout: default
parent: Web forms
nav_order: 8
---

# Indicate required fields in forms

Clearly indicate to the user whether a form field is required to fill out or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify: "Clearly indicate to the user whether a form field is required."

The rest of the sentence is unneeded.

Then the user knows which information they must provide to submit a form.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Then the user can tell what information they must provide..."

In principle, while making this accessible should make it more probable that a user will know what they need, it technically only makes it possible for them to know it. So I don't like saying "they will know this", just that "they can know this".


You have two options:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems awkward as a list. As a sentence, I might go with:

"You can either add a visual indicator for all required fields, or add a visual indicator for all optional fields."

I'm just not convinced that a list of two items is helping the reader.


1. By visually marking required fields.
2. By visually marking non-required fields.

Both are fine, as long as you are consistent within the form and, if possible, also within all forms on your website.

Always place the explanation of how you indicate this above the form, so the user knows beforehand what to expect when completing it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: "Always explain how you are indicating required fields above the form..."

44 changes: 44 additions & 0 deletions docs/topics/forms/required/mark-non-required-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Mark non-required fields
layout: default
parent: Required fields
nav_order: 3
---

# Option 2: Marking only the non-required form fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit "the": "Marking only non-required form fields"

Question: do we want to say "non-required" or "optional"? I feel that optional is clearer and easier to read. Having the variants be "required" and "non-required" means that you have to read more carefully to be sure whether you're looking at the right instructions. This is something consistent through these docs.


Clearly indicate to the user if a form field is optional.

Assuming that you only request essential information in forms, most fields will be required. Then, non-required fields are the exception. You can choose to mark only the optional fields visually. Do this by informing the user above the field and by including the text '(optional)' in the label for non-required fields.

## Example

<figure>
<img src="{{site.baseurl}}/assets/images/mark-non-required-form-fields.png" alt="Screenshot form indicating non-required fields">
<figcaption>
In this screenshot: Above the form the text: "All questions are required except the questions marked as (optional)".
This information is also in the label text: Your Pronouns (optional).
</figcaption>
</figure>

{: .alert }
**Note for developers**: for screen reader users the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Note for developers**: for screen reader users the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.
**Note for developers**: for screen reader users, the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.


## Indication non-required fields in WordPress form plugins
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Indication non-required fields in WordPress form plugins
## Indication of non-required fields in WordPress form plugins


{: .info }
We'd like to invite people familiar with form plugins to help us add instructions for WordPress form plugins. Like possibilities, settings and screenshots.
Please [contact us]({{site.baseurl}}/docs/contact/) if you want to help us with this additional content.
Comment on lines +30 to +31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We'd like to invite people familiar with form plugins to help us add instructions for WordPress form plugins. Like possibilities, settings and screenshots.
Please [contact us]({{site.baseurl}}/docs/contact/) if you want to help us with this additional content.
We want to invite people familiar with form plugins to help us add instructions for WordPress form plugins, including options, settings, and screenshots.
Please [contact us]({{site.baseurl}}/docs/contact/) if you want to help us with this additional content.


## Related WCAG Success Criteria

By indicating required fields, you meet WCAG success criterion [3.3.2 Labels or Instructions (Level A)](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions).

## Related pages in this documentation

- [Option 1: Marking only the required form fields]({{site.baseurl}}/docs/topics/forms/required/mark-required-fields/).

## Resources

- NL Design System [Guidelines for web forms (Dutch content)](https://nldesignsystem.nl/richtlijnen/formulieren/).
- Faizan Ahmed on UX Design World [Optimizing Form Design: Marking Required and Optional Fields in a Better Way](https://uxdworld.com/form-design-required-and-optional-fields/)
54 changes: 54 additions & 0 deletions docs/topics/forms/required/mark-required-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Mark required fields
layout: default
parent: Required fields
nav_order: 2
---

# Option 1: Marking only the required form fields

Clearly indicate to the user if a form field is required to fill out or not. Inform the user above the field how the fields are marked.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Clearly indicate to the user if a form field is required to fill out or not. Inform the user above the field how the fields are marked.
Clearly indicate to the user whether a form field is required. Inform the user above the form how the fields are marked.


If you choose to mark the required field, include the text '(required)', or an equivalent, in the label for required fields.

A required field indicator can be:
- The text (required).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The text (required).
- The text '(required)'.

- An asterisk (\*). If you use an asterisk, explain this above the form. An asterisk on the form field alone is not sufficient; not everyone has this prior knowledge.

## Example

<figure>
<img src="{{site.baseurl}}/assets/images/mark-required-form-fields.png" alt="Screenshot form indicating required fields">
<figcaption>
In this screenshot: Above the form the text: "*" indicates required fields.
This information is also in the label text: Your name *.
</figcaption>
</figure>

{: .alert }
**Note for developers**: for screen reader users the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Note for developers**: for screen reader users the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.
**Note for developers**: for screen reader users, the indication if a field is required must be added in the code with a form field. Read [Mark if a form field is required for screen readers]({{site.baseurl}}/docs/topics/forms/required/required-screen-readers/) about how to do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The construction "if a field is required must be added in the code with a form field" is confusing; I think that could be clarified. It could also be omitted: I think it would be sufficient here to say "Screen readers have specific needs for discovering required fields. Learn how to indicate required fields for screen readers."


## Indication required fields in WordPress form plugins
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Indication required fields in WordPress form plugins
## Indication of required fields in WordPress form plugins


### Gravity Forms

Gravity Forms adds the possibility to select "Required" with each form field. In the form settings you can choose the type of Required Field Indicator. The explanation of this indicator is added automatically above the form.

### Other WordPress form plugins

{: .info }
We'd like to invite people familiar with form plugins to help us add instructions for WordPress form plugins. Like possibilities, settings and screenshots.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We'd like to invite people familiar with form plugins to help us add instructions for WordPress form plugins. Like possibilities, settings and screenshots.
We want to invite people familiar with form plugins to help us add instructions for WordPress form plugins, including options, settings, and screenshots.

Please [contact us]({{site.baseurl}}/docs/contact/) if you want to help us with this additional content.

## Related WCAG Success Criteria

By indicating required fields, you meet WCAG success criterion [3.3.2 Labels or Instructions (Level A)](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions).

## Related pages in this documentation

- [Option 2: Marking only the non-required form fields]({{site.baseurl}}/docs/topics/forms/required/mark-non-required-fields/).

## Resources

- NL Design System [Guidelines for web forms (Dutch content)](https://nldesignsystem.nl/richtlijnen/formulieren/).
- Faizan Ahmed on UX Design World [Optimizing Form Design: Marking Required and Optional Fields in a Better Way](https://uxdworld.com/form-design-required-and-optional-fields/)
64 changes: 64 additions & 0 deletions docs/topics/forms/required/required-screen-readers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Mark required for screen readers
layout: default
parent: Required fields
nav_order: 4
---

# Mark a required form field for screen readers

Screen reader users will have the field announced as required by the HTML attributes `aria-required` or `required` on the form field.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify: "Screen readers announce form fields as required if they have the HTML attributes aria-required or required."


## Basic HTML examples

### Using aria-required="true"

```html

<label for="name">Your name (required)</label>
<input
id="name"
type="text"
name="name"
autocomplete="name"
aria-required="true"
aria-invalid="false"
/>
```

### Using required

```html
<label for="name">Your name (required)</label>
<input
id="name"
type="text"
name="name"
autocomplete="name"
required
aria-invalid="false"
/>
```

The disadvantage of using `required` is, that it triggers the [client-side form validation](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation) of the browser.

At the time of writing, this validation does not meet WCAG accessibility guidelines. The error messages are not specific enough, they disappear after a few seconds, and they currently lack sufficient screen reader support.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very technically, browser validation does meet WCAG guidelines, but only because of the exceptions about the appearance and behavior of the interaction being governed by the user agent and not modified by the author. So I'd argue that this should say "is not accessible", rather than "does not meet WCAG".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Netherlands this is a hard WCAG fail for several SC, I, will add more info and resources why this is not reliable enough at the moment.


If you decide to use `required`, also use `novalidate` on the form element to prevent the browser's form validation from kicking in and enable you to handle validation server-side.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add: "You can write your own custom client-side validation, as long as you ensure that it's accessible!"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree, will add more info and resources why this is not reliable enough at the moment.


```html
<form action="some-url" novalidate>
```

{: .info }
Note: the use of `aria-invalid` will be addressed later in the section Feedback on form errors.

## WCAG Success Criteria

By indicating required fields, you meet WCAG success criterion [3.3.2 Labels or Instructions (Level A)](https://www.w3.org/WAI/WCAG22/quickref/#labels-or-instructions).

## Resources
- MDN [aria-required](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-required).
- MDN [HTML attribute: required](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/required).
- W3C [Validating Input](https://www.w3.org/WAI/tutorials/forms/validation/).
- NL Design System [Guidelines for web forms (Dutch content)](https://nldesignsystem.nl/richtlijnen/formulieren/).
Loading