Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery datepicker numberOfMonths: display current selection month last

I have a jquery datepicker with the numberOfMonths set to 3, currently when I click on the datepicker, the left side month is the current month. In most cases, the user is only going to be selecting a date prior to todays date so I would prefer the current month selected to be the last calendar i.e. March, April, May instead of the current implementation which is May, June, July.

Greatly appreciate any help!

like image 551
Maton Avatar asked May 30 '10 23:05

Maton


People also ask

How to show multiple months in datepicker using datepicker in jQuery?

jQuery UI datepicker provides a option " numberOfMonths ", which allows you to set number of month to display at once. That means, you can show multiple month. To show 2 months together (as shown in image) then set " numberOfMonths " to 2. $ (document).ready (function () { $ ("#txtDate").datepicker ( { numberOfMonths:2 }); });

How to restrict the date selection in jQuery calendar plugin?

The jQuery code for day name format: By using jQuery calendar plugin, you can restrict the date selection as well. For example, your site has an option to pull reporting only for last three months. So you want a user to navigate only to last three months.

How do I customize the datepicker widget?

The datepicker widget provided by jQuery UI is highly customizable and very easy to use. From color scheme customization to choosing option to show a calendar e.g. showing week numbers, multiple months, restricting date ranges and others is just a matter of setting a few lines of options and code.

How to show current date in UI-datepicker?

You can use ui-datepicker-calendar .ui-state-default for main day blocks. The current date or active date can be stand out by using its class: ui-datepicker-calendar .ui-state-active .


1 Answers

Use the showCurrentAtPos option just for that purpose:

Specify where in a multi-month display the current month shows, starting from 0 at the top/left.

The usage looks like this:

$("#datepicker").datepicker({
    numberOfMonths: 3,
    showCurrentAtPos: 2
});​

Since it's zero-based, 2 would be the right-most, you can see a working demo here.

like image 105
Nick Craver Avatar answered Nov 17 '22 18:11

Nick Craver