Skip to main content

Date input

Use the date input component to help users enter a memorable date or one they can easily look up.

When to use this component

Use the date input component when you’re asking users for a date they’ll already know, or can look up without using a calendar.

When not to use this component

Do not use the date input component if users are unlikely to know the exact date of the event you’re asking about.

Read more about how to ask users for dates.

How it works

The date input component consists of 3 fields to let users enter a day, month and year.

The 3 date fields are grouped together in a <fieldset> with a <legend> that describes them, as shown in the examples on this page. This is usually a question, like ‘What is your date of birth?’.

If you’re asking one question per page, you can set the contents of the <legend> as the page heading. This is good practice as it means that users of screen readers will only hear the contents once.

Make sure that any example dates you use in hint text are valid for the question being asked.

You can use the HTML below.

Never automatically tab users between the fields of the date input because this can be confusing and may clash with normal keyboard controls.

If you’re asking more than one question on the page

If you’re asking more than one question on the page, do not set the contents of the <legend> as the page heading. Read more about asking multiple questions on question pages

Use the autocomplete attribute for a date of birth

Use the autocomplete attribute on the date input component when you’re asking for a date of birth. This lets browsers autofill the information on a user’s behalf if they’ve entered it previously.

To do this, set the autocomplete attribute on the 3 fields to bday-day, bday-month and bday-year. See how to do this in the HTML tab in the following example.

Error message

If you’re highlighting the whole date, style all the fields like this:

If you’re highlighting just one field - either the day, month or year - only style the field that has an error. The error message must say which field has an error, like this:

Make sure errors follow the guidance in error message and have specific error messages for specific error states.

If there’s more than one error, show the highest priority error message. In order of priority, show error messages about:

  • missing or incomplete information
  • information that cannot be correct (for example, the number ‘13’ in the month field)
  • information that fails validation for another reason

If nothing is entered

Highlight the date input as a whole.

Say Πληκτρολογήστε [ό,τι είναι]’. For example, ‘Πληκτρολογήστε την ημερομηνία γέννησής σας.’.

If the date is incomplete

Highlight the day, month or year field where the information is missing. If more than one field is missing information, highlight the date input as a whole.

Say ‘[η επιλογή] πρέπει να περιλαμβάνει [ό,τι λείπει]’.

For example, ‘Date of birth must include a month’ or ‘Date of birth must include a day and month’. For example, 'Η ημέρα γέννησης πρέπει να περιλαμβάνει κάποιον μήνα' ή 'Η ημερομηνία γέννησης πρέπει να περιλαμβάνει ημέρα και μήνα'.

If the date entered cannot be correct

For example, ‘13’ in the month field cannot be correct.

Highlight the day, month or year field with the incorrect information. Or highlight the date as a whole if there’s incorrect information in more than one field, or it’s not clear which field is incorrect.

Say ‘[Ό,τι είναι] πρέπει να είναι πραγματική ημερομηνία.

For example, ‘Η ημέρα γέννησης πρέπει να είναι πραγματική ημερομηνία’.

If the date is in the future when it needs to be in the past

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι στο παρελθόν’. For example, ‘Η ημερομηνία γέννησης πρέπει να είναι στο παρελθόν’.

If the date is in the future when it needs to be today or in the past

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι σήμερα ή στο παρελθόν’. For example, ‘Η ημερομηνία γέννησης πρέπει να είναι σήμερα ή στο παρελθόν’.

If the date is in the past when it needs to be in the future

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι στο μέλλον’. For example, ‘Η ημερομηνία που τελειώνει το σεμινάριο πρέπει να είναι στο μέλλον’.

If the date is in the past when it needs to be today or in the future

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι σήμερα ή στο μέλλον’. For example, ‘Η ημερομηνία που τελειώνει το σεμινάριο πρέπει να είναι σήμερα ή στο μέλλον’.

If the date must be the same as or after another date

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι το ίδιο ή αργότερα από [ημερομηνία ή προαιρετική περιγραφή]’. For example, ‘Η ημερομηνία που τελειώνει το σεμινάριο πρέπει να είναι το ίδιο ή αργότερα από 1 Σεπτεμβρίου 2021, όταν ξεκίνησε το σεμινάριο’.

If the date must be after another date

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι μετά από [ημερομηνία ή προαιρετική περιγραφή]’. For example, ‘Η ημερομηνία που τελειώνει το σεμινάριο πρέπει να είναι μετά από την 1 Σεπτεμβρίου 2021’.

If the date must be the same as or before another date

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι ίδια ή πριν από [ημερομηνία ή προαιρετική περιγραφή]’. For example, ‘Η ημερομηνία της εξέτασης πρέπει να είναι ίδια ή πριν από την 1 Σεπτεμβρίου που τελειώνει το σεμινάριο’.

If the date must be before another date

Highlight the date input as a whole.

Say ‘[whatever it is] must be before [date and optional description]’. For example, ‘The date of Gordon’s last exam must be the same as or before 31 August 2017’. Say ‘[ό,τι είναι] πρέπει να είναι πριν από [ημερομηνία ή προαιρετική περιγραφή]’. For example, ‘Η ημερομηνία της εξέτασης πρέπει να είναι πριν από την 1 Σεπτεμβρίου που τελειώνει το σεμινάριο’.

If the date must be between two dates

Highlight the date input as a whole.

Say ‘[ό,τι είναι] πρέπει να είναι μεταξύ [ημερομηνία ] and [ημερομηνία ή προαιρετική περιγραφή]’. For example, ‘Η ημερομηνία έναρξης του σεμιναρίου πρέπει να είναι μεταξύ 1 Σεμτεμβρίου 2021 και 1 Νοεμβρίου 2021’.

Research on this component

More research is needed to determine the extent to which users struggle to enter months as numbers, and whether allowing them to enter months as text is helpful.