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 meet WCAG 2.1 AA accessibility guidelines.