Unobtrusive JavaScript date-picker widgit

Remember folks, this is a testpage for an “as yet unreleased” (i.e. alpha) version of the datePicker. Expect bugs, console errors and crying children - in fact, just try to expect the unexpected.

Keyboard access

Note: All keyboard shortcuts have been taken from the The DHTML Style Guide Working Group (DSGWG) recommendations.

Key Combination Action
Day navigation
page up Previous month
page down Next month
Ctrl + page up Previous year
Ctrl + page down Next year
Space Todays date
Esc Close date-picker (no date selected)
Return Select highlighted date and close date-picker
2 - 7 Select the corresponding day as the first day of the week

DatePicker Demos

Single Input DatePickers

A simple datePicker:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y”

OK, the same datepicker as above but now let’s show some week numbers:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks

Add a status bar:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y

Let’s highlight Monday & Tuesday:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-12

Now set a top & bottom range:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year

Let’s disable the drag & drop functionality:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year disable-drag

Let’s fill the entire grid with selectable dates:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year disable-drag fill-grid

Let’s fill the entire grid again but we’ll disable the selection of the extra dates:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year disable-drag fill-grid-no-select

Let’s set a bespoke final opacity of 80%:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year fill-grid-no-select opacity-80

Let’s now disable the fade in/out animation (and remove the default opacity we’ve just set):

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 range-low-5-week range-high-1-year disable-drag fill-grid-no-select no-animation

Just for fun, let’s now disable some specific dates:

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 disable-drag fill-grid-no-select no-animation disable-xxxx1225 disable-20070201-20070222

Now we’ll enable a few of the dates we’ve just disabled (enabled dates take preferance over disabled):

class=“dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 disable-drag fill-grid-no-select no-animation disable-xxxx1225 disable-20070201-20070222 enable-20070205-20070209

Split Input DatePickers

Using three text inputs:

class="split-date highlight-days-12 fill-grid disable-20080731 no-animation opacity-90 range-low-20060811 range-high-20090913 statusformat-l-cc-sp-d-sp-F-sp-Y show-weeks"

/ /

Using 3 selectLists:

class="highlight-days-67 disable-days-12 split-date range-low-1960-02-13 opacity-99"

Note: I’ve set the lower limit of the datePicker to be (ten years) lower than the lowest possible year you can select using the year selectList in order to test the automatic resetting of the lower/higher date ranges i.e. the year selectList starts at 1970 but the className defined range has been stipulated as 1960; the datePicker should automatically reset the range to be range-low-1970-02-13.

Using a mixture of text input and selectLists:

class="highlight-days-67 split-date"

Single Input (in-line) DatePickers

A simple datePicker:

class=“display-inline dateformat-l-cc-sp-d-S-sp-M-sp-Y”

OK, the same datepicker as above but now let’s show some week numbers and a status bar:

class=“display-inline dateformat-l-cc-sp-d-S-sp-M-sp-Y show-weeks statusformat-l-cc-sp-d-sp-F-sp-Y

View the related “language in the lab” post for this demo.