A date input allows users to enter a date.
Use the date input component to let users enter memorable dates, like dates of birth. The date input component consists of three fields grouped together, to let users enter a day, month and year.
This approach is advised in most cases because it allows for precise input and reduces the chances of making mistakes.
Do:
Do not:
Users might need to pick a date from a selection, for example, to book an appointment. To do this, you can present dates in a calendar format using a date picker.
The three fields in the date input component are grouped together in a fieldset
with a legend
that describes them, as shown in the examples on this page. The legend is usually a question, such as 'What is your date of birth?'.
Use the autocomplete
attribute on the date input component when you're asking for a date of birth. This allows browsers to autofill the information on a user's behalf if they've entered it previously.
The year input is set to accept only a four-digit number while the month and day inputs can accept up to a two-digit number.
All components are responsive and designed to comply with WCAG 2.2 AA accessibility standards. Full compliance depends on using and configuring the components correctly.
To ensure WCAG 2.2 AA compliance for a date input component, proper usage and configuration are essential. Although the component supports accessibility at a basic level, it’s important to minimise redundant entry by retaining any previously entered dates if a user returns to the form. Make sure that the input field is clearly labelled, with guidance on the correct date format, and allow for easy error correction without requiring re-entry of the date.
Adhering to these practices ensures a smoother, more accessible experience that meets compliance standards.