Before reading this article, I highly recommend reading the previous part of the series:
- JQueryUI - Day 1
- JQueryUI - Day 2 (Draggable)
- JQueryUI - Day 3 (Droppable)
- JQueryUI - Day 4 (Resizable)
- JQuery UI - Day 5 (Selectable)
- JQuery UI - Day 6 (Accordion)
- JQuery UI - Day 7 (AutoComplete)
Datepickers in jQueryUI allow users to select a date from a popup or inline calendar. We can customize the date format and language. We can apply several types of restrictions. Input type elements are used for datepicker and the datepicker calendar opens in a small overlay when the associated text field gains focus.
Syntax
$(selector, context).datepicker(options)
Or
$(selector, context).datepicker("action", [params])
Let us take a simple datepicker example.
- <!DOCTYPE html>
- <head runat="server">
- <title></title>
- <link href="http://code.jquery.com/ui/1.10.4/themes/redmond/jquery-ui.css" rel="stylesheet">
- <script src="http://code.jquery.com/jquery-1.10.2.js">
- </script>
- <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js">
- </script>
- <script>
- $(document).ready(function()
- {
- $("#datepicker-1").datepicker();
- });
- </script>
- <style>
- #datepicker-1
- {
- margin-top: 20px;
- }
- #div1
- {
- background-color: coral;
- color: ButtonHighlight;
- font-size: 30px;
- height: 450px;
- width: 1000px;
- text-align: center;
- margin-left: 150px
- }
- </style>
- </head>
- <body>
- <divid="div1">
- <span>************Date-Picker*************</span>
- <divclass="ui-widget">
- <inputtype="text" id="datepicker-1" />
- </div>
- </div>
- </body>
- </html>

Options
|
Option |
Description |
Example |
|
autoSize |
If set to true automatically resize the input field to accommodate dates |
$("#datepicker-1").datepicker({ autoSize: true }); |
|
buttonImage |
Define URL of an image to use to display the datepicker when the showOn is set to “button” or “both” |
$("#datepicker-1").datepicker({ showOn:"button", buttonImage: "/jquery-ui-1.11.4.custom/images/datepicker.gif" }); |
|
buttonText |
Define text to display on the trigger button. |
$("#datepicker-1").datepicker({ showOn:"button", buttonImage: "/jquery-ui-1.11.4.custom/images/datepicker.gif", buttonText: "Select" }); |
|
changeMonth |
Define whether the month should be rendered as a dropdown instead of text. |
$("#datepicker-1").datepicker({ changeMonth: true }); |
|
changeYear |
Define whether the year should be rendered as a dropdown instead of text. |
$("#datepicker-1").datepicker({ changeYear: true }); |
|
currentText |
Define text to display for the current day link. |
$("#datepicker-1").datepicker({ currentText: "Now" }); |
|
dateFormat |
Define the format for parsed and displayed dates. |
$("#datepicker-1").datepicker({ dateFormat: "yy-dd--mm" }); |
|
defaultDate |
Define initial date for the control, overriding the default value of today. |
$("#datepicker-1").datepicker({ defaultDate: +7 }); |
|
firstDay |
Define the first day of week. 0 for Sunday and 6 for Saturday |
$("#datepicker-1").datepicker({ firstDay: 3 }); |
isRTL |
Define whether the current language is drawn from right to left. |
$("#datepicker-1").datepicker({ isRTL: true }); |
maxDate |
Define the maximum selectable date. |
$("#datepicker-1").datepicker({ maxDate: "+1m +2w" }); |
minDate |
Define the minimum selectable date. |
$("#datepicker-1").datepicker({ minDate: "-1m -2w" }); |
nextText |
Define text to display for the next month link. |
$("#datepicker-1").datepicker({ nextText: "Next Month" }); |
numberOfMonths |
Define The number of months to show at once. |
$("#datepicker-1").datepicker({ numberOfMonths: 3 }); |
prevText |
Define text to display for the previous month link. |
$("#datepicker-1").datepicker({ prevText: "Prev Month" }); |
showAnim |
Define the name of the animation used to show and hide the datepicker. |
$("#datepicker-1").datepicker({ showAnim: "fold" }); |
showButtonPanel |
Define whether to display a button pane in the calendar. The button pane contains two buttons, a Today button that links to the current day, and a Done button that closes the datepicker. |
$("#datepicker-1").datepicker({ showButtonPanel: true }); |
showCurrentAtPos |
Define the position the current month if multiple month are defined by numberOfMonths. |
$("#datepicker-1").datepicker({ showCurrentAtPos: 2 }); |
|
showMonthAfterYear |
Define whether to show the month after the year in the header. |
$("#datepicker-1").datepicker({ showMonthAfterYear: true }); |
|
Define whether to display dates in other months (non-selectable) at the start or end of the current month. |
$("#datepicker-1").datepicker({ showOtherMonths: true }); |
|
If set to true ,a column is added to show the week of the year. |
$("#datepicker-1").datepicker({ showWeek: true }); |
|
Define the range of years displayed in the year drop-down. |
$("#datepicker-1").datepicker({ yearRange: "2010-2020" }); |
|
Define the additional text to display after the year in the month headers. |
$("#datepicker-1").datepicker({ yearSuffix: " Year" }); |
Methods





Santhakumar MunuswamyPosted Jan 13, 2016, 9:55 AM
Thanks for nice article. Keep it up
Gowtham KPosted Jan 13, 2016, 8:26 AM
Good one, Thanks for sharing:)
Raja TPosted Jan 13, 2016, 6:40 AM
Nice, Thanks for sharing
Ankit BansalPosted Jan 13, 2016, 1:09 AM
very nice pankaj..
Praveen KumarPosted Jan 12, 2016, 10:54 PM
Very Nice Pankaj