datepicker Interaction — Extends a most controls to provide Datepicker functionality for the user. 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 onFocus and closes automatically onBlur or when a date is selected. For an inline calendar, simply attach the datepicker to a div or span. You can use keyboard shortcuts to drive the datepicker: page up/down - previous/next month ctrl+page up/down - previous/next year ctrl+home - current month or open when closed ctrl+left/right - previous/next day ctrl+up/down - previous/next week enter - accept the selected date ctrl+end - close and erase the date escape - close the datepicker without selection
Examples Default functionality <asp:TextBox runat="server" ID="_Default" /> <Juice:Datepicker runat="server" TargetControlID="_Default" /> Restrict Date Range <asp:TextBox runat="server" ID="_Restrict" /> <Juice:Datepicker runat="server" TargetControlID="_Restrict" MinDate="-20" MaxDate="+1M +10D" /> Icon Trigger <style> .ui-datepicker-trigger { cursor: pointer; margin-left: 4px; position: relative; } </style> <asp:TextBox runat="server" ID="_IconTrigger" /> <Juice:Datepicker runat="server" TargetControlID="_IconTrigger" ButtonImage="/images/calendar-icon.png" ButtonImageOnly="true" ShowOn="both" ButtonText="Show date picker" /> Populate Alternate Field <asp:TextBox runat="server" ID="_Alternate" /> <asp:TextBox runat="server" ID="_AlternateField" ClientIDMode="Static" /> <Juice:Datepicker runat="server" TargetControlID="_Alternate" AltField="#_AlternateField" AltFormat="DD, d MM, yy" />
Properties AltField Type: String Default: "" The jQuery selector for another field that is to be updated with the selected date from the datepicker. Use the altFormat setting to change the format of the date within this field. Leave as blank for no alternate field. jQuery UI Reference → #option-altField AltFormat Type: String Default: "" The 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 formatDate function jQuery UI Reference → #option-altFormat AppendText Type: String Default: "" The text to display after each date field, e.g. to show the required format. jQuery UI Reference → #option-appendText AutoSize Type: Boolean Default: False Set to true to automatically resize the input field to accomodate dates in the current dateFormat. jQuery UI Reference → #option-autoSize ButtonImage Type: String Default: "" The URL for the popup button image. If set, buttonText becomes the alt value and is not directly displayed. jQuery UI Reference → #option-buttonImage ButtonImageOnly Type: Boolean Default: False Set to true to place an image after the field to use as the trigger without it appearing on a button. jQuery UI Reference → #option-buttonImageOnly ButtonText Type: String Default: ... The text to display on the trigger button. Use in conjunction with showOn equal to 'button' or 'both'. jQuery UI Reference → #option-buttonText CalculateWeek Type: String Default: $.datepicker.iso8601Week A function to calculate the week of the year for a given date. The default implementation uses the ISO 8601 definition: weeks start on a Monday; the first week of the year contains the first Thursday of the year. jQuery UI Reference → #option-calculateWeek ChangeMonth Type: Boolean Default: False Allows you to change the month by selecting from a drop-down list. You can enable this feature by setting the attribute to true. jQuery UI Reference → #option-changeMonth ChangeYear Type: Boolean Default: False Allows you to change the year by selecting from a drop-down list. You can enable this feature by setting the attribute to true. Use the yearRange option to control which years are made available for selection. jQuery UI Reference → #option-changeYear CloseText Type: String Default: Done The text to display for the close link. This attribute is one of the regionalisation attributes. Use the showButtonPanel to display this button. jQuery UI Reference → #option-closeText ConstrainInput Type: Boolean Default: True When true entry in the input field is constrained to those characters allowed by the current dateFormat. jQuery UI Reference → #option-constrainInput CurrentText Type: String Default: Today The text to display for the current day link. This attribute is one of the regionalisation attributes. Use the showButtonPanel to display this button. jQuery UI Reference → #option-currentText DateFormat Type: String Default: mm/dd/yy The format for parsed and displayed dates. This attribute is one of the regionalisation attributes. For a full list of the possible formats see the formatDate function. jQuery UI Reference → #option-dateFormat DayNames Type: String[] Default: System.String[] The list of long day names, starting from Sunday, for use as requested via the dateFormat setting. They also appear as popup hints when hovering over the corresponding column headings. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-dayNames DayNamesMin Type: String[] Default: System.String[] The list of minimised day names, starting from Sunday, for use as column headers within the datepicker. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-dayNamesMin DayNamesShort Type: String[] Default: System.String[] The list of abbreviated day names, starting from Sunday, for use as requested via the dateFormat setting. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-dayNamesShort DefaultDate Type: String Default: null Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current 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. jQuery UI Reference → #option-defaultDate Duration Type: String Default: normal Control the speed at which the datepicker appears, it may be a time in milliseconds or a string representing one of the three predefined speeds ("slow", "normal", "fast"). jQuery UI Reference → #option-duration FirstDay Type: Int32 Default: 0 Set the first day of the week: Sunday is 0, Monday is 1, ... This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-firstDay GotoCurrent Type: Boolean Default: False When true the current day link moves to the currently selected date instead of today. jQuery UI Reference → #option-gotoCurrent HideIfNoPrevNext Type: Boolean Default: False Normally the previous and next links are disabled when not applicable (see minDate/maxDate). You can hide them altogether by setting this attribute to true. jQuery UI Reference → #option-hideIfNoPrevNext IsRTL Type: Boolean Default: False True if the current language is drawn from right to left. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-isRTL MaxDate Type: String Default: null Set a maximum selectable date via a Date object or as a string in the current 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 +1w'), or null for no limit. jQuery UI Reference → #option-maxDate MinDate Type: String Default: null Set a minimum selectable date via a Date object or as a string in the current 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. '-1y -1m'), or null for no limit. jQuery UI Reference → #option-minDate MonthNames Type: String[] Default: System.String[] The list of full month names, for use as requested via the dateFormat setting. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-monthNames MonthNamesShort Type: String[] Default: System.String[] The list of abbreviated month names, as used in the month header on each datepicker and as requested via the dateFormat setting. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-monthNamesShort NavigationAsDateFormat Type: Boolean Default: False When true the formatDate function is applied to the prevText, nextText, and currentText values before display, allowing them to display the target month names for example. jQuery UI Reference → #option-navigationAsDateFormat NextText Type: String Default: Next The text to display for the next month link. This attribute is one of the regionalisation attributes. With the standard ThemeRoller styling, this value is replaced by an icon. jQuery UI Reference → #option-nextText NumberOfMonths Type: Int32 Default: 1 Set how many months to show at once. The value can be a straight integer, or can be a two-element array to define the number of rows and columns to display. jQuery UI Reference → #option-numberOfMonths PrevText Type: String Default: Prev The text to display for the previous month link. This attribute is one of the regionalisation attributes. With the standard ThemeRoller styling, this value is replaced by an icon. jQuery UI Reference → #option-prevText SelectOtherMonths Type: Boolean Default: False When true days in other months shown before or after the current month are selectable. This only applies if showOtherMonths is also true. jQuery UI Reference → #option-selectOtherMonths ShortYearCutoff Type: String Default: +10 Set the cutoff year for determining the century for a date (used in conjunction with dateFormat 'y'). If a numeric value (0-99) is provided then this value is used directly. If a string value is provided then it is converted to a number and added to the current year. Once the cutoff year is calculated, any dates entered with a year value less than or equal to it are considered to be in the current century, while those greater than it are deemed to be in the previous century. jQuery UI Reference → #option-shortYearCutoff ShowAnim Type: String Default: show Set the name of the animation used to show/hide the datepicker. Use 'show' (the default), 'slideDown', 'fadeIn', any of the show/hide jQuery UI effects, or '' for no animation. jQuery UI Reference → #option-showAnim ShowButtonPanel Type: Boolean Default: False Whether to show the button panel. jQuery UI Reference → #option-showButtonPanel ShowCurrentAtPos Type: Int32 Default: 0 Specify where in a multi-month display the current month shows, starting from 0 at the top/left. jQuery UI Reference → #option-showCurrentAtPos ShowMonthAfterYear Type: Boolean Default: False Whether to show the month after the year in the header. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-showMonthAfterYear ShowOn Type: String Default: focus Have the datepicker appear automatically when the field receives focus ('focus'), appear only when a button is clicked ('button'), or appear when either event takes place ('both'). jQuery UI Reference → #option-showOn ShowOptions Type: String Default: {} If using one of the jQuery UI effects for showAnim, you can provide additional settings for that animation via this option. jQuery UI Reference → #option-showOptions ShowOtherMonths Type: Boolean Default: False Display dates in other months (non-selectable) at the start or end of the current month. To make these days selectable use selectOtherMonths. jQuery UI Reference → #option-showOtherMonths ShowWeek Type: Boolean Default: False When 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. jQuery UI Reference → #option-showWeek StepMonths Type: Int32 Default: 1 Set how many months to move when clicking the Previous/Next links. jQuery UI Reference → #option-stepMonths WeekHeader Type: String Default: Wk The text to display for the week of the year column heading. This attribute is one of the regionalisation attributes. Use showWeek to display this column. jQuery UI Reference → #option-weekHeader YearRange Type: String Default: c-10:c+10 Control the range of years displayed in the year drop-down: either relative to today's year (-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. jQuery UI Reference → #option-yearRange YearSuffix Type: String Default: "" Additional text to display after the year in the month headers. This attribute is one of the regionalisation attributes. jQuery UI Reference → #option-yearSuffix
Events All events are currently of the type EventHandler. The "sender" parameter is a reference to the control, and should be cast appropriately to access the widget's properties and methods. OnSelect Type: EventHandler Allows you to define your own event when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this refers to the associated input field. jQuery UI Reference → #event-onSelect