Customize datedropper using its options

How to set an option

datedropper options can be set in two ways:

  • using a data attribute;
  • using Javascript when initializing datedropper.

Set an option by using a data attribute

In order to set an option by using a data attribute, add and customize the related attribute on the element on which datedropper has to be executed.

For instance, you can change the date format by simply customizing the selector as follows:

<input type="text" data-dd-format="S M., Y">

Set an option by using Javascript

You can also set an option during the initialization by customizing the related .dateDropper() function variable.

For instance, you can enable the roundtrip option as follows:

$('.roundtrip-input').dateDropper({
roundtrip: true
});

Options and default values

datedropper provides you with several options to customize your date pickers. Options marked as PRO are available only with datedropper Pro.

Index

 LitePro
format
lang
theme
fx
fxMobile
modal
large
largeDefault
largeOnly
hideDay
hideMonth
hideYear
maxYear
minYear
jump
lock
startFromMonday
defaultDate
maxDate
minDate
disabledDays
enabledDays
showOnlyEnabledDays
roundtrip
autoIncrease
changeValueTo
eventListener
trigger
autofill

Basic options

format

Data attributedata-dd-format
.dateDropper() variableformat

Use the format option to customize the format of the date returned by datedropper.

Features

Typestring
Defaultm/d/Y
Permitted valuesY (four digit year value, e.g. 2019)
F (full name of the month, e.g. January)
M (short name of the month, e.g. Jan)
l (full name of the weekday, e.g. Monday)
D (short name of the weekday, e.g. Mon)
m (month in numbers with leading zero, e.g. 01)
n (month in numbers without leading zero, e.g. 1)
d (weekday in numbers with leading zero, e.g. 01)
j (weekday in numbers without leading zero, e.g. 1)
S (weekday in numbers with a suffix ending, e.g. 1st)
U (Unix timestamp, e.g. 1577750400)

Examples

Sample configuration with data attribute

<input type="text" data-dd-format="d-m-Y">

Sample configuration with Javascript

$('#my-input').dateDropper({
format: 'd-m-Y'
});

lang

Data attributedata-dd-lang
.dateDropper() variablelang

Use the lang option to set the language of your date picker.

Features

Typestring
Defaulten
Available languagesar (Arabic)
da (Danish)
de (German)
es (Spanish)
fr (French)
gr (Greek)
hu (Hungarian)
it (Italian)
ko (Korean)
nl (Dutch)
pl (Polish)
pt (Portuguese)
ru (Russian)
si (Slovenian)
tr (Turkish)
uk (Ukrainian)

Examples

Sample configuration with data attribute

<input type="text" data-dd-lang="es">

Sample configuration with Javascript

$('#my-input').dateDropper({
lang: 'es'
});

Styling options

theme

Data attributedata-dd-theme
.dateDropper() variabletheme

Use the theme option to set the datedropper theme. Learn more on all the available themes and on how to create your own style.

Features

Typestring
Defaultvanilla

Examples

Sample configuration with data attribute

<input type="text" data-dd-theme="leaf">

Sample configuration with Javascript

$('#my-input').dateDropper({
theme: 'leaf'
});

fx and fxMobile

Data attributedata-dd-fxdata-dd-fx-mobile
.dateDropper() variablefxfxMobile

Use the fx and the fxMobile options to enable or disable any animations/transitions. fxMobile option only affects mobile devices.

Features

Typeboolean
Defaulttrue

Examples

Sample configuration with data attribute

<input type="text" data-dd-fx="true" data-dd-fx-mobile="false">

Sample configuration with Javascript

$('#my-input').dateDropper({
fx: true,
fxMobile: false
});
Data attributedata-dd-modal
.dateDropper() variablemodal

Set the modal option as true in order to open the date picker as a modal window with an overlay on the background.

Features

Typeboolean
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-modal="true">

Sample configuration with Javascript

$('#my-input').dateDropper({
modal: true
});

large

Data attributedata-dd-large
.dateDropper() variablelarge

Set the large option as true to enable a button that opens the date picker as a calendar.

Features

Typeboolean
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-large="true">

Sample configuration with Javascript

$('#my-input').dateDropper({
large: true
});

largeDefault

Data attributedata-dd-large-default
.dateDropper() variablelargeDefault

Set the largeDefault option as true to open the date picker as a calendar by default.

Features

Typeboolean
Default
false

Examples

Sample configuration with data attribute

<input type="text" data-dd-large-default="true">

Sample configuration with Javascript

$('#my-input').dateDropper({
largeDefault: true
});

largeOnly

Data attributedata-dd-large-only
.dateDropper() variablelargeOnly

Set the largeOnly option as true to only open the date picker as a calendar.

Features

Typeboolean
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-large-only="true">

Sample configuration with Javascript

$('#my-input').dateDropper({
largeOnly: true
});

hideDay, hideMonth and hideYear

Data attributedata-dd-hide-daydata-dd-hide-monthdata-dd-hide-year
.dateDropper() variablehideDayhideMonthhideYear

Set these options as true to hide the day, the month and/or the year block from the date picker.

Features

Typeboolean
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-hide-day="true" data-dd-hide-month="true" data-hide-year="false">

Sample configuration with Javascript

$('#my-input').dateDropper({
hideDay: true,
hideMonth: true,
hideYear: false
});

Customizing dates and any other features

maxYear and minYear

Data attributedata-dd-max-yeardata-dd-min-year
.dateDropper() variablemaxYearminYear

Use the maxYear and minYear options to set the maximum and minimum selectable years.

The selected year must be provided in the format yyyy (e.g. '2019').

Features

maxYear

Typeinteger
DefaultcurrentYear

minYear

Typeinteger
Default1970

Examples

Sample configuration with data attribute

<input type="text" data-dd-max-year="2050" data-dd-min-year="2000">

Sample configuration with Javascript

$('#my-input').dateDropper({
maxYear: 2050,
minYear: 2000
});

jump

Data attributedata-dd-jump
.dateDropper() variablejump

If the jump option is set as true, by clicking on the years block the user will be allowed to move through the years between minYear and maxYear in multiples of the value defined with the jump option.

Features

Typeinteger/false
Default10

Examples

Sample configuration with data attribute

<input type="text" data-dd-jump="5">

Sample configuration with Javascript

$('#my-input').dateDropper({
jump: 5
});

lock

Data attributedata-dd-lock
.dateDropper() variablelock

Set the lock option as equal to from or to if you want to make the dates selectable from or up to the current date.

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-lock="from">

Sample configuration with Javascript

$('#my-input').dateDropper({
lock: 'from'
});

startFromMonday

Data attributedata-dd-start-from-monday
.dateDropper() variablestartFromMonday

Set the startFromMonday option as false to start the week from Sunday.

Features

Typeboolean
Defaulttrue

Examples

Sample configuration with data attribute

<input type="text" data-dd-start-from-monday="false">

Sample configuration with Javascript

$('#my-input').dateDropper({
startFromMonday: false
});

defaultDate

Data attributedata-dd-default-date
.dateDropper() variabledefaultDate

Use the defaultDate option to select the default date set when opening the date picker. Keep in mind that the default date must be provided in the format mm/dd/yyyy (e.g. '12/31/2019').

Features

Typestring/object/null
Defaultnull

Examples

Sample configuration with data attribute

<input type="text" data-dd-default-date="12/31/2019">

Sample configuration with Javascript

$('#my-input').dateDropper({
defaultDate: '12/31/2019'
});

maxDate and minDate

Data attributedata-dd-max-datedata-dd-min-date
.dateDropper() variablemaxDateminDate

Use the maxDate and the minDate options if you want to make the dates selectable until or from the defined date.

The date must be provided in the format mm/dd/yyyy (e.g. '12/31/2019').

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-max-date="12/31/2019">

Sample configuration with Javascript

$('#my-input').dateDropper({
minDate: '12/31/2019'
});

disabledDays

Data attributedata-dd-disabled-days
.dateDropper() variabledisabledDays

When enabled, the disabledDays option allows you to disable one or more dates. Dates must be provided in the format mm/dd/yyyy, comma separated (e.g. '12/30/2019,12/31/2019').

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-disabled-days="12/30/2019,12/31/2019">

Sample configuration with Javascript

$('#my-input').dateDropper({
disabledDays: '12/30/2019,12/31/2019'
});

enabledDays

Data attributedata-dd-enabled-days
.dateDropper() variableenabledDays

When enabled, the enabledDays option allows you to only enable the selected dates. Dates must be provided in the format mm/dd/yyyy, comma separated (e.g. '12/30/2019,12/31/2019').

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-enabled-days="12/30/2019,12/31/2019">

Sample configuration with Javascript

$('#my-input').dateDropper({
enabledDays: '12/30/2019,12/31/2019'
});

showOnlyEnabledDays

Data attributedata-dd-show-only-enabled-days
.dateDropper() variableshowOnlyEnabledDays

The showOnlyEnabledDays option only works when the enabledDays option is defined and, if set as true, it shows only the available dates by using the date picker compact version. Therefore, this option overwrites the large, largeDefault and largeOnly options.

Features

Typeboolean
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-enabled-days="12/30/2019,12/31/2019" data-dd-show-only-enabled-days="true">

Sample configuration with Javascript

$('#my-input').dateDropper({
enabledDays: '12/30/2019,12/31/2019',
showOnlyEnabledDays: true
});

roundtrip

Data attributedata-dd-roundtrip
.dateDropper() variableroundtrip

The roundtrip option can be set up on one or two elements by defining a custom value (e.g. data-dd-roundtrip="trip"). If you set it on two elements, use the same value for both the elements. When enabled, this option allows the user to select outward and return dates from the same date picker.

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input id="outward-date" type="text" data-dd-roundtrip="my-trip">
<input id="return-date" type="text" data-dd-roundtrip="my-trip">

Sample configuration with Javascript

$('input').dateDropper({
roundtrip: 'my-trip'
});

autoIncrease

Data attributedata-dd-auto-increase
.dateDropper() variableautoIncrease

By default, when the user clicks on the date picker arrows to advance by one day, and it's the last day of the month or year, datedropper will automatically jump to the next month or year. Set the autoIncrease option as false to disable this behavior.

Features

Typeboolean
Defaulttrue

Examples

Sample configuration with data attribute

<input type="text" data-dd-auto-increase="false">

Sample configuration with Javascript

$('#my-input').dateDropper({
autoIncrease: false
});

Advanced options

changeValueTo

Data attributedata-dd-change-value-to
.dateDropper() variablechangeValueTo

Use the changeValueTo option to define a selector to which datedropper should pass the value set on the date picker. Keep in mind that this selector must be an input.

Features

Typestring
Defaultnull

Examples

Sample configuration with data attribute

<button class="datedropper-init" data-dd-change-value-to="#my-input">Open datepicker</button>
<input id="my-input"/>

Sample configuration with Javascript

$('button').dateDropper({
changeValueTo: '#my-input'
});

eventListener

Data attributedata-dd-event-listener
.dateDropper() variableeventListener

Use the eventListener option to define the event through which the selector should activate datedropper. By default, the date picker is enabled on focus.

Features

Typestring
Defaultfocus

Examples

Sample configuration with data attribute

<input type="text" data-dd-event-selector="click">

Sample configuration with Javascript

$('#my-input').dateDropper({
eventSelector: 'click'
});

trigger

Data attributedata-dd-trigger
.dateDropper() variabletrigger

A click on the trigger selector activates the eventListener of the datedropper element.

Features

Typestring/false
Defaultfalse

Examples

Sample configuration with data attribute

<input type="text" data-dd-trigger="#my-trigger">

Sample configuration with Javascript

$('#my-input').dateDropper({
trigger: '.my-trigger'
});

autofill

Data attributedata-dd-autofill
.dateDropper() variableautofill

By default, datedropper automatically fills out the selector with the selected date whenever it moves or gets initialized. Set the autofill option as false to disable this behavior.

Features

Typeboolean
Defaulttrue

Examples

Sample configuration with data attribute

<input type="text" data-dd-autofill="false">

Sample configuration with Javascript

$('#my-input').dateDropper({
autofill: false
});

Related articles