Set Date range to one month in jQuery datepicker

In this post, I will show you how can you set the selected date range to only one month from the current date in jQuery UI datepicker. jQuery UI datepicker provides 2 options minDate and maxDate. minDate option allows you to set minimum selectable date in datepicker. Default is null which means no limit. Where maxDate option allows you to set maximum selectable date in datepicker. Default is null so no limit.

For both these options you can set a 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.

To set date range of one month from current date, we will use 'M' option to "+1" for maxDate and for minDate "0" So the current date becomes the value of minDate. See below jQuery code.

$(document).ready(function(){
    $("#txtDate").datepicker({ minDate: 0, maxDate: '+1M', numberOfMonths:2 });
});
See live Demo and Code.

Read my other posts related to jQuery UI Datepicker.

1. Implement jQueryUI DatePicker with ASP.NET
2. Show Hand/Pointer cursor on image button with jQueryUI datepicker control
3. Disable Weekends in jQuery DatePicker
4. Enable weekends in jQuery Datepicker
5. Disable specific days in jQuery Datepicker
6. jQuery Datepicker does not work after Ajax Partial Postback
7. Show multiple months in jQuery UI datepicker

Feel free to contact me for any help related to jQuery. I will gladly help you.



Responsive Menu
Add more content here...