Bootstrap-datepicker: Disable (grey out) past dates or future dates in datepicker?

Created on 20 Jan 2013  路  5Comments  路  Source: uxsolutions/bootstrap-datepicker

Is it possible to grey out all future days in the date picker? So that the user can only select today or any previous dates?

And also vice versa, where the user can only select future dates and cannot select any dates in the past?

These two features would be very handy.

Most helpful comment

Try this, it is working in my case:

$(function () {   
        $('#Datein').datetimepicker(
            {
                daysOfWeekDisabled: [0],
                format: 'MM/DD/YYYY',                    
                ignoreReadonly: true,
                maxDate: 'now'
            }
          );
    });

All 5 comments

Sorry I just realized, startDate and endDate come already with a default min and max date already, hence thats perfectly possible. Great plugin. Thanks

This is a FAQ, should be on the wiki.

Answer solved on #438. (Y)
Also Try this :

    $(function () {
            var date = new Date();
            var currentMonth = date.getMonth();
            var currentDate = date.getDate();
            var currentYear = date.getFullYear();
            $('#datetimepicker,#datetimepicker1').datetimepicker({
                                    pickTime: false,
                format: "DD-MM-YYYY",   
                maxDate: new Date(currentYear, currentMonth, currentDate)
            });
        });

Best Solution for disable future date...
var date=new Date();
$('#datetimepicker').datetimepicker({
format: 'MM/dd/yyyy',
language: 'en',
startDate : new Date('2015-01-01'),
endDate : date
});

Try this, it is working in my case:

$(function () {   
        $('#Datein').datetimepicker(
            {
                daysOfWeekDisabled: [0],
                format: 'MM/DD/YYYY',                    
                ignoreReadonly: true,
                maxDate: 'now'
            }
          );
    });
Was this page helpful?
0 / 5 - 0 ratings