Date pickers
Date pickers use a dialog window to select a single date on mobile.
A date picker has to be activated via JavaScript.
N.B. Date picker requires material.js
or material.min.js
.
Options
Alternatively, options can be passed on to override some default datepicker behaviours.
Option | Description |
---|---|
cancel | Change the text of the cancel button or use cancel: '' to hide the button. Default is 'Cancel' . |
closeOnCancel | Close the picker when the cancel button is clicked. Default is true . Set to false to change this behaviour. |
closeOnSelect | Close the picker when a date is selected. Default is false . Set to true to change this behaviour. |
container | Change where to insert the datepicker element by passing any valid CSS selector. By default, the picker is inserted right after the associated input element. |
containerHidden | By default, the picker’s hidden input is inserted right after the main input element. Specify where to insert the hidden element by passing any valid CSS selector to this option. |
disable | Disable a date or a set of dates from being selectable in the picker. See below for detailed usage. |
firstDay | Change the first day of the week. Default is 0 which sets it to Sunday. Set it to Monday by changing the value to 1 . |
format | Set the date format. See below for a full list of available date format rules. |
formatSubmit | Optionally, set a different date format for the value to be submitted to the server. When formatSubmit is specified, a hidden input with the same name attribute as the original will be created to hold the value. |
hiddenName | Set to true to only send the hidden value hold by the hidden input created by setting formatSubmit to the server. Setting this to true essentially nullifies the hiddenPrefix and hiddenSuffix , strips the name attribute from the source input, and then sets it as the name of the hidden input. |
hiddenPrefix hiddenSuffix |
Add optional prefix/suffix to the name attribute of the hidden input that is created by setting formatSubmit . |
labelMonthNext labelMonthPrev labelMonthSelect labelYearSelect |
Change the accessibility labels (i.e. title attributes) to several elements of the picker. |
max | Set the maximum selectable date. See below for detailed usage. |
min | Set the minimum selectable date. See below for detailed usage. |
monthsFull | Change labels of months. |
monthsShort | Change abbreviations of months. |
ok | Change the text of the OK button or set it to '' to hide the button. Default is 'OK' . |
onClose, onOpen, onRender, onSet, onStart, onStop |
Fire events as the user interacts with the picker. Within scope of these events, this refers to the picker. |
selectMonths | Default is false . Set it to true to display a dropdown menu to pick the month. |
selectYears | Default is false . Set it to true to display a dropdown menu to pick the year or use an even integer to specify the number of years to be shown in the dropdown menu (half after and the other half before the year in focus). |
today | Change the text of the today button or pass an empty value to hide the button: today: '' . Default is 'Today' . |
weekdaysFull | Change labels of weekdays. |
weekdaysShort | Change abbreviations of weekdays. |
Date limit
Maximum and minimum selectable dates can be set on the picker.
Disable dates
Disable a specific or arbitrary set of dates selectable on the picker.
The values for from
and to
can be:
- Array formatted as
[YEAR,MONTH,DATE]
- JavaScript date
true
to set it as “today”
The values can also be integers representing dates relative to the other:
Formatting rules
The following rules can be used to format any date:
Rule | Description | Result |
---|---|---|
d |
Date of the month | 1 – 31 |
dd |
Date of the month with a leading zero | 01 – 31 |
ddd |
Day of the week in short form | Sun – Sat |
dddd |
Day of the week in full form | Sunday – Saturday |
m |
Month of the year | 1 – 12 |
mm |
Month of the year with a leading zero | 01 – 12 |
mmm |
Month name in short form | Jan – Dec |
mmmm |
Month name in full form | January – December |
yy |
Year in short form * | 00 – 99 |
yyyy |
Year in full form | 2000 – 2999 |