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.
Asked
Active
Viewed 587 times
0
-
1can you add code of your try? – rala Mar 20 '17 at 08:47
-
1Possible 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 Answers
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
-
-
Please at least mark the answer as accepted as this solves the problem in your question. Thanks! – acrobat Mar 22 '17 at 14:17