0

I am using bootstrap datepicker for delivery date. But I want to disable two dates after current date so that it will atleast take two days to prepare product after placing an order.

sakpal
  • 28
  • 4
  • 1
    can you add code of your try? – rala Mar 20 '17 at 08:47
  • 1
    Possible duplicate of [How to restrict the selectable date ranges in Bootstrap Datepicker?](http://stackoverflow.com/questions/11933173/how-to-restrict-the-selectable-date-ranges-in-bootstrap-datepicker) – rala Mar 20 '17 at 08:49

1 Answers1

0

You can solve this problem with the beforeShowDay callback.

var today = new Date();
var deliveryThreshold = new Date();
deliveryThreshold.setDate(deliveryThreshold.getDate() + 2);

$('#datepicker').datepicker({
    //..
    startDate: '+1d',
    beforeShowDay: function(date) {
        if (date >= today && date <= deliveryThreshold) {
        return false;
      }
    }
});

Example: http://jsfiddle.net/zcvq0yhh/205/

acrobat
  • 2,179
  • 2
  • 27
  • 35