Change Default Date and Month in Jquery Data Picker


We can change default date display date in jquery data picker as we wanted like moving months back and forward and displaying particular date.

As we all know script for jquery date picker, I'm just recalling the script again.



Following shows some examples for changes defaults options.




Above code changes the default month to previous two months. Example, if we are in November I'll show us the month of September. 

By passing in a string like following ways, we can set the default date to another one relative to the current date. Alternatively, the option also accepts a Date object: or a string in the same format as the format currently defined: defaultDate: '1/9/2010'




If we use defaultDate it will highlight that particular day, following method just shows the previous month with nothing selected, where '1'  shows the previous month. You can change the number however you want. I'll give us that particular month. Example, if you we give 12, it shows previous 12th month from current month. Likewise we can give any number.



Even we can change year as well in data picker. Code is as follows.



Above code shows date of  next 7 months and next 7 years from current date.

Note: We need to use latest version of jquery, juqery-ui.js and jquery-ui.css for data picker.

Comments

Popular posts from this blog

Gradient Border Colors with CSS

10 Useful Libraries and Resources for Responsive Web Design

The Simplest Way To Center Elements Vertically And Horizontally