Options guide of datedropper JS

Try the new datedropper JS configurator to easily get the best plugin configuration!
Configure now

How to Configure Options

Datedropper offers two ways to configure options, allowing you to customize its behavior to meet your needs:

  • Using data attributes directly in the HTML markup.
  • Using JavaScript during the initialization process.

Configuring Options with Data Attributes

To configure options using data attributes, simply add and customize the relevant attributes in kebab-case format (e.g., data-option-[OPTION_KEY]) to the element where datedropper is applied.

For example, you can adjust the date format and make the calendar expandable by setting the following attributes:

<input 
  type="text" 
  data-option-format="y-mm-dd" 
  data-option-expandable="true"
/>

Configuring Options with JavaScript

Alternatively, you can set options programmatically during the initialization by customizing the datedropper function. When using JavaScript, options must be specified in camelCase format.

new dateDropper('#myInput', {
  format: "y-mm-dd",
expandable: true });

Options and default values

datedropper provides you with several options to customize your date picker.

Basic options

Advanced options


Basic options


selector

This option sets the elements that will run the datepicker. It basically excecutes a querySelectorAll of the selector specified.

Typestring/false
Defaultfalse

EXAMPLES

new dateDropper('input');

format

Use the format option to customize the format of the output date.

Typestring
Defaultmm/dd/y

ALLOWED VALUES

yfour digit year value, e.g. 2019
MMfull name of the month, e.g. January
Mshort name of the month, e.g. Jan
WWfull name of the weekday, e.g. Monday
Wshort name of the weekday, e.g. Mon
wweekday number, as per getDay() javascript function, e.g. 1
mmmonth in numbers with leading zero, e.g. 01
mmonth in numbers without leading zero, e.g. 1
ddweekday in numbers with leading zero, e.g. 01
dweekday in numbers without leading zero, e.g. 1
Sweekday in numbers with a suffix ending, e.g. 1st
UUnix timestamp, e.g. 1577750400

EXAMPLES

Sample configuration with data attribute

<input type="text" data-option-format="mm-dd-y">

Sample configuration with Javascript

new dateDropper('#myInput', {
  format: 'd-m-y'
});

Language Option

The lang option allows you to set the language of the date picker. By default, the language is set to English, but you can change it to another language. To do this, download the corresponding language library from the list below, include it in the <head> section of your HTML after the dateDropper script, and then configure the desired language in the dateDropper options, as shown below.

Features

Typestring
Defaulten

Available Languages

arArabicDownload
daDanishDownload
deGermanDownload

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  lang: 'es'
});

Custom Language Template

You can add a custom language by using the following template. Replace the values with your translations and update the LANGUAGE_CODE with your chosen language code.

dateDropperSetup.languages[LANGUAGE_CODE] = {
  "name": "Your Language Name",
  "m": {
    "s": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
    "f": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  },
  "w": {
    "s": ["S", "M", "T", "W", "T", "F", "S"],
    "f": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  },
  "labels": {
    "confirm": "%s has been selected. Press enter to confirm.",
    "invalid": "You can't select %s based on calendar options.",
    "select": "Choose date",
    "title": "DateDropper calendar view",
    "expand": "Make calendar larger",
    "collapse": "Make calendar smaller",
    "back": "Back to main years dialog",
    "selected": "%s selected",
    "arrows": "Use keyboard arrows left and right to navigate.",
    "y": {
      "selector": "Years selector",
      "prev": "Previous year",
      "next": "Next year"
    },
    "m": {
      "selector": "Months selector",
      "prev": "Previous month",
      "next": "Next month"
    },
    "d": {
      "selector": "Days selector",
      "prev": "Previous day",
      "next": "Next day"
    }
  }
};
new dateDropper('#myInput', {
  lang: LANGUAGE_CODE
});

showArrowsOnHover

This option controls the visibility of the navigation arrows. If set to false, the arrows will always be visible, regardless of hover actions.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-show-arrows-on-hover="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  showArrowsOnHover: false
});

customClass

The customClass option allows you to add a custom CSS class to the parent node of the datepicker. This is useful for customizing the appearance of the datepicker. Learn more about customizing the datepicker style.

Typestring
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-custom-class="myClass">

Configuration using JavaScript:

new dateDropper('#myInput', {
  customClass: 'myClass'
});

overlay

Enable the overlay option by setting it to true to obscure the background with an overlay. This is particularly useful for focusing the user's attention on the datepicker.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-overlay="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  overlay: true
});

defaultDate

The defaultDate option allows you to set a specific default date for the date picker. Note that the date must be provided in the standard format yyyy/mm/dd (e.g., '2019/03/28').

Typestring
Defaultfalse

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  defaultDate: '2019/12/31'
});

Advanced Options


expandable

Enable the expandable option by setting it to true to allow users to toggle the date picker to an expanded calendar view.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-expandable="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  expandable: true
});

expandedDefault

Use the expandedDefault option to open the date picker with the expanded calendar view by default. Set this option to true to enable it.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-expanded-default="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  expandedDefault: true
});

expandedOnly

The expandedOnly option ensures that the date picker opens exclusively in the expanded calendar view. Set this option to true to enable it.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-expanded-only="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  expandedOnly: true
});

doubleView

When the doubleView option is set to true and the datepicker is in expanded mode, it displays two calendar views instead of one, enabling easier range selection.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-double-view="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  doubleView: true
});

preset

The preset option allows you to customize the appearance of the datepicker by choosing a specific structure. This option supports predefined presets to tailor the behavior of the datepicker.

Typeboolean
Defaultfalse

Presets

OptionResult
onlyMonthDisplays a datepicker with only the month selector.
onlyYearDisplays a datepicker with only the year selector.

Examples

Configuration using a data attribute:

<input type="text" data-option-preset="onlyMonth">

Configuration using JavaScript:

new dateDropper('#myInput', {
  preset: 'onlyMonth'
});

maxYear and minYear

Use the maxYear and minYear options to define the maximum and minimum selectable years. These values should be provided in the format yyyy (e.g., '2019').

OptionTypeDefault
minYearintegercurrentYear - 50
maxYearintegercurrentYear + 50

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  maxYear: 2050,
  minYear: 2000
});

jump

The jump option allows the user to move through years in increments, as defined by its value, by clicking on the years block. The range is restricted between minYear and maxYear.

Typeinteger/false
Default10

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  jump: 5
});

startFromMonday

Set the startFromMonday option to true to make the week start on Monday instead of Sunday.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-start-from-monday="true">

Configuration using JavaScript:

new dateDropper('#myInput', {
  startFromMonday: true
});

maxDate and minDate

Use the maxDate and minDate options to restrict the selectable dates to a specific range. Dates must be formatted as yyyy/mm/dd (e.g., '2019/03/28').

OptionTypeDefault
maxDatestringfalse
minDatestringfalse

Examples

Configuration using a data attribute:

<input type="text" data-option-max-date="2022/12/31" data-option-min-date="2021/01/01">

Configuration using JavaScript:

new dateDropper('#myInput', {
  maxDate: "2022/12/31",
  minDate: "2021/01/01"
});

disabledDays

The disabledDays option disables specific dates in the datepicker. Dates must be formatted as yyyy/mm/dd and provided as a comma-separated list (e.g., '2019/12/30,2019/12/31').

Typestring/false
Defaultfalse

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  disabledDays: "2019/12/30,2019/12/31"
});

enabledDays

The enabledDays option allows you to enable only the specified dates. Dates must be formatted as yyyy/mm/dd and provided as a comma-separated list (e.g., '2019/12/30,2019/12/31').

Typestring/false
Defaultfalse

Examples

Configuration using a data attribute:

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

Configuration using JavaScript:

new dateDropper('#myInput', {
  enabledDays: "2019/12/30,2019/12/31"
});

range

The range option can be used with one or two inputs. When enabled, it allows the selection of a start and an end date within the same date picker. If two inputs are used, the first will be filled with the start date, and the second with the end date.

Typestring/false
Defaultfalse

Examples

Configuration using multiple inputs:

<input id="outward-date" type="text">
<input id="return-date" type="text">

Configuration using JavaScript:

new dateDropper('#myInput', {
  range: true
});

minRange and maxRange

These options limit the range of selectable days when using the range option. The values indicate the minimum and maximum number of days that can be selected, and they only work when the range option is enabled.

Typeinteger/boolean
Defaultfalse

Examples

Configuration using a data attribute:

<input id="myInput" type="text" data-option-min-range="8" data-option-max-range="12">

Configuration using JavaScript:

new dateDropper('#myInput', {
  minRange: 8,
  maxRange: 12
});

rangeStart & rangeEnd

Use these options to set default start and end dates for the range. The dates must be formatted as yyyy/mm/dd.

Typestring
Defaultfalse

Examples

Configuration using a data attribute:

<input id="myInput" type="text" data-option-range-start="2021/04/01" data-option-range-end="2021/04/10">

Configuration using JavaScript:

new dateDropper('#myInput', {
  rangeStart: "2021/04/01",
  rangeEnd: "2021/04/10"
});

disabledWeekDays

This option allows you to disable specific days of the week. Each number corresponds to a specific weekday. Use a comma-separated list to specify the days.

Typestring/array
Defaultfalse

Value

Sunday0
Monday1
Tuesday2
Wednesday3
Thursday4
Friday5
Saturday6

Examples

Configuration using a data attribute:

<input type="text" data-option-disabled-week-days="0,6">

Configuration using JavaScript:

new dateDropper('#myInput', {
  disabledWeekDays: '0,6'
});

changeValueTo

Use the changeValueTo option to define a selector where the selected date should be passed. The selector must be an input element.

Typestring
Defaultnull

Examples

HTML:

<button class="myDatedropper" data-option-change-value-to="#myInput">Open datepicker</button>
<input id="myInput" />

JavaScript:

new dateDropper({
  selector: '#myDatedropper',
  changeValueTo: '#myInput'
});

autoFill

By default, dateDropper automatically fills the input with the selected date when it initializes or the date changes. Set the autoFill option to false to disable this behavior.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-auto-fill="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  autoFill: false
});

loopAll

If set to false, this option locks navigation and hides the arrows in the focused block (day, month, year) when the minimum or maximum value is reached.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-loop-all="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  loopAll: false
});

loopYears

If set to false, this option locks navigation and hides the arrows in the year block when the minimum or maximum year is reached.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-loop-years="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  loopYears: false
});

loopMonths

If set to false, this option locks navigation and hides the arrows in the month block when the minimum or maximum month is reached.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-loop-months="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  loopMonths: false
});

loopDays

If set to false, this option locks navigation and hides the arrows in the day block when the minimum or maximum day is reached.

Typeboolean
Defaulttrue

Examples

Configuration using a data attribute:

<input type="text" data-option-loop-days="false">

Configuration using JavaScript:

new dateDropper('#myInput', {
  loopDays: false
});

inline

By default, dateDropper is a dialog window that appears around the trigger when activated. If the inline option is set to true, the datepicker will be appended directly inside the selector node (suggested to be a <div>) as a standalone dialog.

Typeboolean
Defaultfalse

Examples

Configuration using a data attribute:

<div id="myInput" data-option-inline="true"></div>

Configuration using JavaScript:

new dateDropper('#myInput', {
  inline: true
});