When Datepicker object is attached to an <input>
element, it's configured as a regular date picker.
When Datepicker object is attached to a block element, it's configured as an inline picker.
data-date
attributeDate range picker is essentially a wrapper/controller of 2 date pickers. It's the only type of DateRangePicker object.
<input>
elements<input>
elementsThe view to select a date. The days are displayed in monthly calendar layout. Optionally, ISO week numbers can be shown in the view.
The view to select a month. The months are shown in short name.
The view to select a year.
The view to select a decade.
When maxNumberOfDates
config option is set to other than 1
, date picker turns to the multdate mode.
In this mode, the day cells in the days view act as toggle switch of the date's select status. The order of selection is kept; newly selected date is appended to the existing selection and the oldest item in the selection drops if the number of selected dates exceeds the option's value.
In the input field, selected dates are joined with the delimiter string set in the dateDelimiter
config option.
Multidate mode is not applied to the pickers of date range picker.
Datepicker accepts date string, Date object or time value for the source of a date. All given dates are parsed/converted into the internal date value individually.
The time value of local time
00:00:00.000
of the date is used for the internal date value.
The dates before January 1st, 0000 are not supported because the built-in parser cannot handle negative numbers. (-
sign is one of the predefined separator characters)
To provide dates for config options or API method arguments, you can just follow the above general rules.
To provide initial date selection to a date picker, you can set a date string to the <input>
element's value
attribute. This also works for date range picker's <input>
elements.
For inline picker, you can set a date string to the data-date
attribute of the element to attach the picker.
You can update the selected date by editing the date string in the input field.
Since the built-in parser is very tolerant of format errors, a small typing error can cause an unexpected (and sometimes unimaginable) date in the input field. (See How Built-in Parser parses)
If you think this is not good, you might want to consider using theupdateOnBlur
:false
config option in order to implicitly nudge users to look at their input.
You can operate date picker using keyboard. Here are the available keyboard operations.
When picker is hidden
When picker is shown
When in edit mode
Note: Keyboard operation is not supported by inline picker.
When the picker element is shown, date picker (in the primary state) captures key-press events and uses them to control the picker element. Therefore, users cannot edit the <input>
element in this state.
To solve this, Datepicker has the edit mode.
Date picker automatically enters edit mode when:
<input>
element is clickedand exits edit mode when:
While date picker is in edit mode,
<input>
element becomes more prominent