-
Notifications
You must be signed in to change notification settings - Fork 4
Adds topic required form fields to the Web forms section #210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe: "Always explain how you are indicating required fields above the form..." |
||
| 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 | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## Indication non-required fields in WordPress form plugins | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| {: .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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| ## 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/) | ||||||||||
| 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. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| 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). | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| - 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. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ### 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. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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/) | ||||||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| ## 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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".
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!"
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/). | ||
Uh oh!
There was an error while loading. Please reload this page.