Date and time selector

This topic discusses design standards and rules for date and time selection. This article is related to the Form Elements pattern. See Form Elements for general rules on form usage and placement.

When to Use

Use this element whenever a date, date range, time or time range needs to be gathered from the user.

Variations

Single Date Picker

Date Range Picker

Single Time Picker

Time Range Picker

Single Date and Time Picker

Date and Time Range Picker

Formats

Date:

Time:

Interaction

Disabled State

The following applies to ranges only:

(Styles will support a disabled state for areas which depend on sequence for ranges)

Time Selection Behaviors

Within the calendar widget, the following will apply to time fields:

Text Field Entry & Validation

Note:

MM/DD/YYYY can be confused with DD/MM/YYYY, so please assume the following:

Field selection works the same as a typical text field with

Style

Single Date Picker:

Date Range Picker:

Single Time Picker:

Time Range Picker:

Single Date and Time Picker:

Date and Time Range Picker:

Accessibility

Date or Time Input Fields

The initial text field assumes the typical tab orders used in form field pattern.

Date Picker Widget

Reference: Date Picker Widget

As a general rule the actual calendar portion of the date picker should follow a table structure where days of the week and calendar day numbers are laid out in table cells. This provides context so an assistive technology can render the day of the week; its corresponding numeric calendar day, and week number if necessary. Consequently, it is best to start with an HTML table and apply WAI-ARIA semantics for a grid. However, should the author wish to uses a div or span to represent the cells then the DOM structure for a table should be duplicated with rows marked with role="row."

Keyboard Interactions

Keyboard navigation on days that are not included the currently displayed month should move to the month automatically and lead to the day in the next or previous month.

Do not implement keyboard navigation schemes that would place more than one calendar day in the tab order at any time as this impacts the usability of keyboard navigation. For example, using HTML anchors for the gridcells places them all in the tab order impacting the usability of keyboard navigation.

WAI-ARIA Roles, States, and Properties

When the datepicker is active a calendar day of the week should always have focus. This can be achieved by setting the tabindex on that day as appropriate and then using script to give it focus. Alternatively, the grid container could set aria-activedescendant to the id of the currently focused gridcell. Keep in mind that older browsers may not support aria-activedescendant.

Time Picker Widget

Implementation

Date and time selectors are implemented using the standard jQuery UI datepicker widget and addon.