jQuery UI DatePicker – Display Multiple Months

Here’s how to display multiple months in the jQuery UI DatePicker using the ‘numberOfMonths’ option.

<label>Multiple Month DatePicker: </label>
<
input id="date2" />
<
script type="text/javascript">
$(function() {
var dt = {
numberOfMonths: 2
};
$("#date2").datepicker(dt);
});
</script>

image

You can even change the DatePicker UI using the different options available. For example, if you wanted to display the year as a dropdown field and also specify the range of years in the dropdown, use the following code:

<body>
<
label>Multiple Month DatePicker: </label>
<
input id="date2" />
<
script type="text/javascript">
$(function() {
var dt = {
changeYear: true,
yearRange: "-3:+3"
};
$("#date2").datepicker(dt);
});
</script>
</
body>

image

The UI shown above displays the year as a dropdown field and displays a range of 3 years both backwards and forward. You can check similar DatePicker options over here to configure the jQuery UI DatePicker

2 comments:

  1. Excellent tip, thanks very much for sharing, there is really smart material in this Web site.

    ReplyDelete
  2. thanks but how to show permanent ??

    ReplyDelete