Datepicker Widgetversion added: 1.0
Description: Select a date from a popup or inline calendar
The jQuery UI Datepicker is a highly configurable plugin that adds datepicker functionality to your pages. You can customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.
By default, the datepicker calendar opens in a small overlay when the associated text field gains focus. For an inline calendar, simply attach the datepicker to a div or span.
Keyboard interaction
While the datepicker is open, the following key commands are available:
- PAGE UP: Move to the previous month.
- PAGE DOWN: Move to the next month.
- CTRL+PAGE UP: Move to the previous year.
- CTRL+PAGE DOWN: Move to the next year.
- CTRL+HOME: Move to the current month. Open the datepicker if closed.
- CTRL+LEFT: Move to the previous day.
- CTRL+RIGHT: Move to the next day.
- CTRL+UP: Move to the previous week.
- CTRL+DOWN: Move the next week.
- ENTER: Select the focused date.
- CTRL+END: Close the datepicker and erase the date.
- ESCAPE: Close the datepicker without selection.
Utility functions
- $.datepicker.setDefaults( settings ) - Set settings for all datepicker instances.
- $.datepicker.formatDate( format, date, settings ) - Format a date into a string value with a specified format.
- $.datepicker.parseDate( format, value, settings ) - Extract a date from a string value with a specified format.
- $.datepicker.iso8601Week( date ) - Determine the week of the year for a given date: 1 to 53.
- $.datepicker.noWeekends - Set as beforeShowDay function to prevent selection of weekends.
Localization
Datepicker provides support for localizing its content to cater for different languages and date formats. Each localization is contained within its own file with the language code appended to the name, e.g., jquery.ui.datepicker-fr.js
for French. The desired localization file should be included after the main datepicker code. Each localization file adds its settings to the set of available localizations and automatically applies them as defaults for all instances.
The $.datepicker.regional
attribute holds an array of localizations, indexed by language code, with ""
referring to the default (English). Each entry is an object with the following attributes: closeText
, prevText
, nextText
, currentText
, monthNames
, monthNamesShort
, dayNames
, dayNamesShort
, dayNamesMin
, weekHeader
, dateFormat
, firstDay
, isRTL
, showMonthAfterYear
, and yearSuffix
.
You can restore the default localizations with:
$.datepicker.setDefaults( $.datepicker.regional[ "" ] );
And can then override an individual datepicker for a specific locale:
$( selector ).datepicker( $.datepicker.regional[ "fr" ] );
Additional Notes:
- This widget requires some functional CSS, otherwise it won't work. If you build a custom theme, use the widget's specific CSS file as a starting point.
Options
altFieldType: Selector or jQuery or Element
""
altFormat
option to change the format of the date within this field. Leave as blank for no alternate field.Initialize the datepicker with the altField option specified:
$( ".selector" ).datepicker({ altField: "#actualDate" }); |
Get or set the altField option, after initialization:
// getter var altField = $( ".selector" ).datepicker( "option" , "altField" ); // setter $( ".selector" ).datepicker( "option" , "altField" , "#actualDate" ); |
altFormatType: String
""
dateFormat
to be used for the altField
option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the [[UI/Datepicker/formatDate|formatDate]] functionInitialize the datepicker with the altFormat option specified:
$( ".selector" ).datepicker({ altFormat: "yy-mm-dd" }); |
Get or set the altFormat option, after initialization:
// getter var altFormat = $( ".selector" ).datepicker( "option" , "altFormat" ); // setter $( ".selector" ).datepicker( "option" , "altFormat" , "yy-mm-dd" ); |
appendTextType: String
""
Initialize the datepicker with the appendText option specified:
$( ".selector" ).datepicker({ appendText: "(yyyy-mm-dd)" }); |
Get or set the appendText option, after initialization:
// getter var appendText = $( ".selector" ).datepicker( "option" , "appendText" ); // setter $( ".selector" ).datepicker( "option" , "appendText" , "(yyyy-mm-dd)" ); |
autoSizeType: Boolean
false
true
to automatically resize the input field to accommodate dates in the current dateFormat
.Initialize the datepicker with the autoSize option specified:
$( ".selector" ).datepicker({ autoSize: true }); |
Get or set the autoSize option, after initialization:
// getter var autoSize = $( ".selector" ).datepicker( "option" , "autoSize" ); // setter $( ".selector" ).datepicker( "option" , "autoSize" , true ); |
beforeShowType: Function( Element input, Object inst )
null
beforeShowDayType: Function( Date date )
null
[0]
equal to true
/false
indicating whether or not this date is selectable, [1]
equal to a CSS class name or ""
for the default presentation, and [2]
an optional popup tooltip for this date. It is called for each day in the datepicker before it is displayed.calculateWeekType: Function()
jQuery.datepicker.iso8601Week
Initialize the datepicker with the calculateWeek option specified:
$( ".selector" ).datepicker({ calculateWeek: myWeekCalc }); |
Get or set the calculateWeek option, after initialization:
// getter var calculateWeek = $( ".selector" ).datepicker( "option" , "calculateWeek" ); // setter $( ".selector" ).datepicker( "option" , "calculateWeek" , myWeekCalc ); |
changeMonthType: Boolean
false
Initialize the datepicker with the changeMonth option specified:
$( ".selector" ).datepicker({ changeMonth: true }); |
Get or set the changeMonth option, after initialization:
// getter var changeMonth = $( ".selector" ).datepicker( "option" , "changeMonth" ); // setter $( ".selector" ).datepicker( "option" , "changeMonth" , true ); |
changeYearType: Boolean
false
yearRange
option to control which years are made available for selection.Initialize the datepicker with the changeYear option specified:
$( ".selector" ).datepicker({ changeYear: true }); |
Get or set the changeYear option, after initialization:
// getter var changeYear = $( ".selector" ).datepicker( "option" , "changeYear" ); // setter $( ".selector" ).datepicker( "option" , "changeYear" , true ); |
closeTextType: String
"Done"
showButtonPanel
option to display this button.Initialize the datepicker with the closeText option specified:
$( ".selector" ).datepicker({ closeText: "Close" }); |
Get or set the closeText option, after initialization:
// getter var closeText = $( ".selector" ).datepicker( "option" , "closeText" ); // setter $( ".selector" ).datepicker( "option" , "closeText" , "Close" ); |
constrainInputType: Boolean
true
true
, entry in the input field is constrained to those characters allowed by the current dateFormat
option.Initialize the datepicker with the constrainInput option specified:
$( ".selector" ).datepicker({ constrainInput: false }); |
Get or set the constrainInput option, after initialization:
// getter var constrainInput = $( ".selector" ).datepicker( "option" , "constrainInput" ); // setter $( ".selector" ).datepicker( "option" , "constrainInput" , false ); |
currentTextType: String
"Today"
showButtonPanel
option to display this button.Initialize the datepicker with the currentText option specified:
$( ".selector" ).datepicker({ currentText: "Now" }); |
Get or set the currentText option, after initialization:
// getter var currentText = $( ".selector" ).datepicker( "option" , "currentText" ); // setter $( ".selector" ).datepicker( "option" , "currentText" , "Now" ); |
dateFormatType: String
"mm/dd/yy"
[[UI/Datepicker/formatDate|formatDate]]
function.Initialize the datepicker with the dateFormat option specified:
$( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" }); |
Get or set the dateFormat option, after initialization:
// getter var dateFormat = $( ".selector" ).datepicker( "option" , "dateFormat" ); // setter $( ".selector" ).datepicker( "option" , "dateFormat" , "yy-mm-dd" ); |
dayNamesType: Array
[ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
dateFormat
option.Initialize the datepicker with the dayNames option specified:
$( ".selector" ).datepicker({ dayNames: [ "Dimanche" , "Lundi" , "Mardi" , "Mercredi" , "Jeudi" , "Vendredi" , "Samedi" ] }); |
Get or set the dayNames option, after initialization:
// getter var dayNames = $( ".selector" ).datepicker( "option" , "dayNames" ); // setter $( ".selector" ).datepicker( "option" , "dayNames" , [ "Dimanche" , "Lundi" , "Mardi" , "Mercredi" , "Jeudi" , "Vendredi" , "Samedi" ] ); |
dayNamesMinType: Array
[ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ]
Initialize the datepicker with the dayNamesMin option specified:
$( ".selector" ).datepicker({ dayNamesMin: [ "Di" , "Lu" , "Ma" , "Me" , "Je" , "Ve" , "Sa" ] }); |
Get or set the dayNamesMin option, after initialization:
// getter var dayNamesMin = $( ".selector" ).datepicker( "option" , "dayNamesMin" ); // setter $( ".selector" ).datepicker( "option" , "dayNamesMin" , [ "Di" , "Lu" , "Ma" , "Me" , "Je" , "Ve" , "Sa" ] ); |
dayNamesShortType: Array
[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]
dateFormat
option.Initialize the datepicker with the dayNamesShort option specified:
$( ".selector" ).datepicker({ dayNamesShort: [ "Dim" , "Lun" , "Mar" , "Mer" , "Jeu" , "Ven" , "Sam" ] }); |
Get or set the dayNamesShort option, after initialization:
// getter var dayNamesShort = $( ".selector" ).datepicker( "option" , "dayNamesShort" ); // setter $( ".selector" ).datepicker( "option" , "dayNamesShort" , [ "Dim" , "Lun" , "Mar" , "Mer" , "Jeu" , "Ven" , "Sam" ] ); |
defaultDateType: Date or Number or String
null
[[UI/Datepicker#option-dateFormat|dateFormat]]
, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.- Date: A date object containing the default date.
-
Number: A number of days from today. For example
2
represents two days from today and-1
represents yesterday. -
String: A string in the format defined by the
dateFormat
option, or a relative date. Relative dates must contain value and period pairs; valid periods are"y"
for years,"m"
for months,"w"
for weeks, and"d"
for days. For example,"+1m +7d"
represents one month and seven days from today.
Initialize the datepicker with the defaultDate option specified:
$( ".selector" ).datepicker({ defaultDate: +7 }); |
Get or set the defaultDate option, after initialization:
// getter var defaultDate = $( ".selector" ).datepicker( "option" , "defaultDate" ); // setter $( ".selector" ).datepicker( "option" , "defaultDate" , +7 ); |
durationType: or String
"normal"
Initialize the datepicker with the duration option specified:
$( ".selector" ).datepicker({ duration: "slow" }); |
Get or set the duration option, after initialization:
// getter var duration = $( ".selector" ).datepicker( "option" , "duration" ); // setter $( ".selector" ).datepicker( "option" , "duration" , "slow" ); |
firstDayType: Integer
0
0
, Monday is 1
, etc.Initialize the datepicker with the firstDay option specified:
$( ".selector" ).datepicker({ firstDay: 1 }); |
Get or set the firstDay option, after initialization:
// getter var firstDay = $( ".selector" ).datepicker( "option" , "firstDay" ); // setter $( ".selector" ).datepicker( "option" , "firstDay" , 1 ); |
gotoCurrentType: Boolean
false
true
, the current day link moves to the currently selected date instead of today.Initialize the datepicker with the gotoCurrent option specified:
$( ".selector" ).datepicker({ gotoCurrent: true }); |
Get or set the gotoCurrent option, after initialization:
// getter var gotoCurrent = $( ".selector" ).datepicker( "option" , "gotoCurrent" ); // setter $( ".selector" ).datepicker( "option" , "gotoCurrent" , true ); |
hideIfNoPrevNextType: Boolean
false
minDate
and maxDate
options). You can hide them altogether by setting this attribute to true
.Initialize the datepicker with the hideIfNoPrevNext option specified:
$( ".selector" ).datepicker({ hideIfNoPrevNext: true }); |
Get or set the hideIfNoPrevNext option, after initialization:
// getter var hideIfNoPrevNext = $( ".selector" ).datepicker( "option" , "hideIfNoPrevNext" ); // setter $( ".selector" ).datepicker( "option" , "hideIfNoPrevNext" , true ); |
isRTLType: Boolean
false
Initialize the datepicker with the isRTL option specified:
$( ".selector" ).datepicker({ isRTL: true }); |
Get or set the isRTL option, after initialization:
// getter var isRTL = $( ".selector" ).datepicker( "option" , "isRTL" ); // setter $( ".selector" ).datepicker( "option" , "isRTL" , true ); |
maxDateType: Date or Number or String
null
null
, there is no maximum.- Date: A date object containing the maximum date.
-
Number: A number of days from today. For example
2
represents two days from today and-1
represents yesterday. -
String: A string in the format defined by the
dateFormat
option, or a relative date. Relative dates must contain value and period pairs; valid periods are"y"
for years,"m"
for months,"w"
for weeks, and"d"
for days. For example,"+1m +7d"
represents one month and seven days from today.
Initialize the datepicker with the maxDate option specified:
$( ".selector" ).datepicker({ maxDate: "+1m +1w" }); |
Get or set the maxDate option, after initialization:
// getter var maxDate = $( ".selector" ).datepicker( "option" , "maxDate" ); // setter $( ".selector" ).datepicker( "option" , "maxDate" , "+1m +1w" ); |
minDateType: Date or Number or String
null
null
, there is no minimum.- Date: A date object containing the minimum date.
-
Number: A number of days from today. For example
2
represents two days from today and-1
represents yesterday. -
String: A string in the format defined by the
dateFormat
option, or a relative date. Relative dates must contain value and period pairs; valid periods are"y"
for years,"m"
for months,"w"
for weeks, and"d"
for days. For example,"+1m +7d"
represents one month and seven days from today.
Initialize the datepicker with the minDate option specified:
$( ".selector" ).datepicker({ minDate: new Date(2007, 1 - 1, 1) }); |
Get or set the minDate option, after initialization:
// getter var minDate = $( ".selector" ).datepicker( "option" , "minDate" ); // setter $( ".selector" ).datepicker( "option" , "minDate" , new Date(2007, 1 - 1, 1) ); |
monthNamesType: Array
[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
dateFormat
option.Initialize the datepicker with the monthNames option specified:
$( ".selector" ).datepicker({ monthNames: [ "Januar" , "Februar" , "Marts" , "April" , "Maj" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "December" ] }); |
Get or set the monthNames option, after initialization:
// getter var monthNames = $( ".selector" ).datepicker( "option" , "monthNames" ); // setter $( ".selector" ).datepicker( "option" , "monthNames" , [ "Januar" , "Februar" , "Marts" , "April" , "Maj" , "Juni" , "Juli" , "August" , "September" , "Oktober" , "November" , "December" ] ); |
monthNamesShortType: Array
[ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]
dateFormat
option.Initialize the datepicker with the monthNamesShort option specified:
$( ".selector" ).datepicker({ monthNamesShort: [ "Jan" , "Feb" , "Mar" , "Apr" , "Maj" , "Jun" , "Jul" , "Aug" , "Sep" , "Okt" , "Nov" , "Dec" ] }); |
Get or set the monthNamesShort option, after initialization:
// getter var monthNamesShort = $( ".selector" ).datepicker( "option" , "monthNamesShort" ); // setter $( ".selector" ).datepicker( "option" , "monthNamesShort" , [ "Jan" , "Feb" , "Mar" , "Apr" , "Maj" , "Jun" , "Jul" , "Aug" , "Sep" , "Okt" , "Nov" , "Dec" ] ); |
nextTextType: String
"Next"
Initialize the datepicker with the nextText option specified:
$( ".selector" ).datepicker({ nextText: "Later" }); |
Get or set the nextText option, after initialization:
// getter var nextText = $( ".selector" ).datepicker( "option" , "nextText" ); // setter $( ".selector" ).datepicker( "option" , "nextText" , "Later" ); |
numberOfMonthsType: Number or Array
1
- Number: The number of months to display in a single row.
- Array: An array defining the number of rows and columns to display.
Initialize the datepicker with the numberOfMonths option specified:
$( ".selector" ).datepicker({ numberOfMonths: [ 2, 3 ] }); |
Get or set the numberOfMonths option, after initialization:
// getter var numberOfMonths = $( ".selector" ).datepicker( "option" , "numberOfMonths" ); // setter $( ".selector" ).datepicker( "option" , "numberOfMonths" , [ 2, 3 ] ); |
onChangeMonthYearType: Function( Integer year, Integer month, Object inst )
null
this
refers to the associated input field.onCloseType: Function( String dateText, Object inst )
null
""
if none) and the datepicker instance as parameters. this
refers to the associated input field.onSelectType: Function( String dateText, Object inst )
null
this
refers to the associated input field.prevTextType: String
"Prev"
Initialize the datepicker with the prevText option specified:
$( ".selector" ).datepicker({ prevText: "Earlier" }); |
Get or set the prevText option, after initialization:
// getter var prevText = $( ".selector" ).datepicker( "option" , "prevText" ); // setter $( ".selector" ).datepicker( "option" , "prevText" , "Earlier" ); |
selectOtherMonthsType: Boolean
false
showOtherMonths
option is set to true
.Initialize the datepicker with the selectOtherMonths option specified:
$( ".selector" ).datepicker({ selectOtherMonths: true }); |
Get or set the selectOtherMonths option, after initialization:
// getter var selectOtherMonths = $( ".selector" ).datepicker( "option" , "selectOtherMonths" ); // setter $( ".selector" ).datepicker( "option" , "selectOtherMonths" , true ); |
shortYearCutoffType: Number or String
"+10"
[[UI/Datepicker#option-dateFormat|dateFormat]]
'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century.-
Number: A value between
0
and99
indicating the cutoff year. -
String: A relative number of years from the current year, e.g.,
"+3"
or"-5"
.
Initialize the datepicker with the shortYearCutoff option specified:
$( ".selector" ).datepicker({ shortYearCutoff: 50 }); |
Get or set the shortYearCutoff option, after initialization:
// getter var shortYearCutoff = $( ".selector" ).datepicker( "option" , "shortYearCutoff" ); // setter $( ".selector" ).datepicker( "option" , "shortYearCutoff" , 50 ); |
showAnimType: String
"show"
"show"
(the default), "slideDown"
, "fadeIn"
, any of the jQuery UI effects. Set to an empty string to disable animation.Initialize the datepicker with the showAnim option specified:
$( ".selector" ).datepicker({ showAnim: "fold" }); |
Get or set the showAnim option, after initialization:
// getter var showAnim = $( ".selector" ).datepicker( "option" , "showAnim" ); // setter $( ".selector" ).datepicker( "option" , "showAnim" , "fold" ); |
showButtonPanelType: Boolean
false
Initialize the datepicker with the showButtonPanel option specified:
$( ".selector" ).datepicker({ showButtonPanel: true }); |
Get or set the showButtonPanel option, after initialization:
// getter var showButtonPanel = $( ".selector" ).datepicker( "option" , "showButtonPanel" ); // setter $( ".selector" ).datepicker( "option" , "showButtonPanel" , true ); |
showCurrentAtPosType: Number
0
numberOfMonths
option, the showCurrentAtPos
option defines which position to display the current month in.Initialize the datepicker with the showCurrentAtPos option specified:
$( ".selector" ).datepicker({ showCurrentAtPos: 3 }); |
Get or set the showCurrentAtPos option, after initialization:
// getter var showCurrentAtPos = $( ".selector" ).datepicker( "option" , "showCurrentAtPos" ); // setter $( ".selector" ).datepicker( "option" , "showCurrentAtPos" , 3 ); |
showMonthAfterYearType: Boolean
false
Initialize the datepicker with the showMonthAfterYear option specified:
$( ".selector" ).datepicker({ showMonthAfterYear: true }); |
Get or set the showMonthAfterYear option, after initialization:
// getter var showMonthAfterYear = $( ".selector" ).datepicker( "option" , "showMonthAfterYear" ); // setter $( ".selector" ).datepicker( "option" , "showMonthAfterYear" , true ); |
showOnType: String
"focus"
"focus"
), when a button is clicked ("button"
), or when either event occurs ("both"
).Initialize the datepicker with the showOn option specified:
$( ".selector" ).datepicker({ showOn: "both" }); |
Get or set the showOn option, after initialization:
// getter var showOn = $( ".selector" ).datepicker( "option" , "showOn" ); // setter $( ".selector" ).datepicker( "option" , "showOn" , "both" ); |
showOptionsType: Object
{}
showAnim
option, you can provide additional settings for that animation via this option.Initialize the datepicker with the showOptions option specified:
$( ".selector" ).datepicker({ showOptions: { direction: "up" } }); |
Get or set the showOptions option, after initialization:
// getter var showOptions = $( ".selector" ).datepicker( "option" , "showOptions" ); // setter $( ".selector" ).datepicker( "option" , "showOptions" , { direction: "up" } ); |
showOtherMonthsType: Boolean
false
selectOtherMonths
option.Initialize the datepicker with the showOtherMonths option specified:
$( ".selector" ).datepicker({ showOtherMonths: true }); |
Get or set the showOtherMonths option, after initialization:
// getter var showOtherMonths = $( ".selector" ).datepicker( "option" , "showOtherMonths" ); // setter $( ".selector" ).datepicker( "option" , "showOtherMonths" , true ); |
showWeekType: Boolean
false
true
, a column is added to show the week of the year. The calculateWeek
option determines how the week of the year is calculated. You may also want to change the firstDay
option.Initialize the datepicker with the showWeek option specified:
$( ".selector" ).datepicker({ showWeek: true }); |
Get or set the showWeek option, after initialization:
// getter var showWeek = $( ".selector" ).datepicker( "option" , "showWeek" ); // setter $( ".selector" ).datepicker( "option" , "showWeek" , true ); |
stepMonthsType: Number
1
Initialize the datepicker with the stepMonths option specified:
$( ".selector" ).datepicker({ stepMonths: 3 }); |
Get or set the stepMonths option, after initialization:
// getter var stepMonths = $( ".selector" ).datepicker( "option" , "stepMonths" ); // setter $( ".selector" ).datepicker( "option" , "stepMonths" , 3 ); |
weekHeaderType: String
"Wk"
showWeek
option to display this column.Initialize the datepicker with the weekHeader option specified:
$( ".selector" ).datepicker({ weekHeader: "W" }); |
Get or set the weekHeader option, after initialization:
// getter var weekHeader = $( ".selector" ).datepicker( "option" , "weekHeader" ); // setter $( ".selector" ).datepicker( "option" , "weekHeader" , "W" ); |
yearRangeType: String
"c-10:c+10"
"-nn:+nn"
), relative to the currently selected year ("c-nn:c+nn"
), absolute ("nnnn:nnnn"
), or combinations of these formats ("nnnn:-nn"
). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the minDate
and/or maxDate
options.Initialize the datepicker with the yearRange option specified:
$( ".selector" ).datepicker({ yearRange: "2002:2012" }); |
Get or set the yearRange option, after initialization:
// getter var yearRange = $( ".selector" ).datepicker( "option" , "yearRange" ); // setter $( ".selector" ).datepicker( "option" , "yearRange" , "2002:2012" ); |
yearSuffixType: String
""
Initialize the datepicker with the yearSuffix option specified:
$( ".selector" ).datepicker({ yearSuffix: "CE" }); |
Get or set the yearSuffix option, after initialization:
// getter var yearSuffix = $( ".selector" ).datepicker( "option" , "yearSuffix" ); // setter $( ".selector" ).datepicker( "option" , "yearSuffix" , "CE" ); |
Methods
destroy()
- This method does not accept any arguments.
Invoke the destroy method:
$( ".selector" ).datepicker( "destroy" ); |
dialog( date [, onSelect ] [, settings ] [, pos ] )
-
dateThe initial date.
-
onSelectType: Function()A callback function when a date is selected. The function receives the date text and date picker instance as parameters.
-
settingsType: OptionsThe new settings for the date picker.
-
posType: Number[2] or MouseEventThe position of the top/left of the dialog as
[x, y]
or aMouseEvent
that contains the coordinates. If not specified the dialog is centered on the screen.
Invoke the dialog method:
$( ".selector" ).datepicker( "dialog" , "10/12/2012" ); |
getDate()Returns: Date
null
if no date has been selected.- This method does not accept any arguments.
Invoke the getDate method:
var currentDate = $( ".selector" ).datepicker( "getDate" ); |
hide()
- This method does not accept any arguments.
Invoke the hide method:
$( ".selector" ).datepicker( "hide" ); |
isDisabled()Returns: Boolean
- This method does not accept any arguments.
Invoke the isDisabled method:
var isDisabled = $( ".selector" ).datepicker( "isDisabled" ); |
option( optionName )Returns: Object
optionName
.-
optionNameType: StringThe name of the option to get.
Invoke the method:
var isDisabled = $( ".selector" ).datepicker( "option" , "disabled" ); |
option()Returns: PlainObject
- This method does not accept any arguments.
Invoke the method:
var options = $( ".selector" ).datepicker( "option" ); |
option( optionName, value )
optionName
.-
optionNameType: StringThe name of the option to set.
-
valueType: ObjectA value to set for the option.
Invoke the method:
$( ".selector" ).datepicker( "option" , "disabled" , true ); |
option( options )
-
optionsType: ObjectA map of option-value pairs to set.
Invoke the method:
$( ".selector" ).datepicker( "option" , { disabled: true } ); |
refresh()
- This method does not accept any arguments.
Invoke the refresh method:
$( ".selector" ).datepicker( "refresh" ); |
setDate( date )
Date
object or a string in the current date format (e.g., "01/26/2009"
), a number of days from today (e.g., +7
) or a string of values and periods ("y"
for years, "m"
for months, "w"
for weeks, "d"
for days, e.g., "+1m +7d"
), or null
to clear the selected date.-
dateThe new date.
Invoke the setDate method:
$( ".selector" ).datepicker( "setDate" , "10/12/2012" ); |
show()
- This method does not accept any arguments.
Invoke the show method:
$( ".selector" ).datepicker( "show" ); |
widget()Returns: jQuery
jQuery
object containing the datepicker.
- This method does not accept any arguments.
Invoke the widget method:
var widget = $( ".selector" ).datepicker( "widget" ); |
Example:
A simple jQuery UI Datepicker.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <!doctype html> < html lang = "en" > < head > < meta charset = "utf-8" > < title >datepicker demo</ title > </ head > < body > < div id = "datepicker" ></ div > < script > $( "#datepicker" ).datepicker(); </ script > </ body > </ html > |