Skip to main content
Coat of arms of Barbados
Official government website

Date Input

Lets users enter a memorable date, such as a date of birth.

Preview

Date of birth

The Date Input component lets users enter a memorable date, such as a date of birth or a document's expiry date, using three short text fields for day, month, and year. A shared <fieldset> and <legend> group the three fields under a single question.

When to use this component

Use a date input for dates the user already knows and can recall unassisted, such as a date of birth, a passport expiry date, or an anniversary. Typing three short numbers is faster and more reliable than operating a calendar widget for dates like these.

When not to use this component

Do not use a date input when the user needs to look up a date rather than recall it, for example choosing the next available appointment slot or selecting a date range. Use a date picker instead, so the user can browse a calendar and see which dates are available.

Labels and hint text

Give the fieldset a clear <legend> that states the question, such as "Date of birth", and label each field "Day", "Month", and "Year". Use hint text (.govbb-hint) below the legend to show an example format, such as "For example, 27 3 1990", and link it to the fieldset with aria-describedby. Set inputmode="numeric" on each field so mobile keyboards show digits, and do not require leading zeros: accept both "3" and "03".

Errors

Validate the whole date together on the server and report a single error message (.govbb-error-message) above the fields with role="alert", rather than one error per field. Mark every field in the group with aria-invalid="true" so screen reader users understand the whole date is in question, not just one part of it.

Date of birth with error