ManiMuthuPandi
ManiMuthuPandi

Reputation: 1604

How to disable upcoming dates in Bootstrap datepicker

Is there a way to disable upcoming dates in Bootstrap datepicker.

I have read some of the questions already for disabling dates in the past, and tried the below code

$('.date_time_picker .date_disp input').datepicker({
            format: "yyyy-mm-dd",
            startDate:'-0d' // this prevents dates from yesterday
});

How can we disable future / upcoming dates and want to show only dates from this year.

So I should have the visible date ranges should be from 2018-01-01 to current date (2018-05-15)

Upvotes: 1

Views: 134

Answers (1)

jarvo69
jarvo69

Reputation: 8339

To disable future dates try below code:

$('.date_time_picker .date_disp input').datepicker({
            format: "yyyy-mm-dd",
            startDate:'-0d' // this prevents dates from yesterday
     endDate: '+0d' //this prevents dates from future being enabled to be selected

});

endDate: '+0d' is what you need

Upvotes: 3

Related Questions