Set maxDate on jquery ui datepicker to certain date

this worked for me by setting the end date picker range from today to 7 more days.

$endDateCtrl.datepicker("option", "minDate", -0);
$endDateCtrl.datepicker("option", "maxDate", '+7D');
$endDateCtrl.datepicker();

I am setting max date using event functions:

    $('#datepicker').datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "-9:+1",// you can define range of year here.
        dateFormat: 'MM yy',
        onClose: function () {

            var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();

            var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();

            $(this).datepicker('setDate', new Date(iYear, iMonth, 1));

        },
        beforeShow: function () {
            var selDate = $(this).val();
            if ((selDate.length) > 0) {
                iYear = selDate.substring(selDate.length - 4, selDate.length);
                iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5),

                $(this).datepicker('option', 'monthNames'));
                $(this).datepicker('option', 'defaultDate', new Date(lastYear, iMonth, 1));
                $(this).datepicker('option', 'maxDate', new Date(lastYear, 12, 1));
                $(this).datepicker('setDate', new Date(lastYear, iMonth, 1));
            }
        }
    });

Try this:

$("#datepicker").datepicker({ minDate: -0, maxDate: new Date(2013, 1, 18) });

If you want use hard coded date, use the new Date(2013, 1, 18) pattern.

If you want to use generic pattern, use "+1D +1M +1Y".

Reference link: http://jsfiddle.net/pradkumar_n/wQe8c/


$( "#datepicker" ).datepicker( { minDate: 0, maxDate: 365 });
//365 Days

You can use number of days also.