MonstroDev MonstroDev - 4 months ago 205
Javascript Question

Bootstrap Date Range Picker disable dates

How do I block the availability of some dates in Date Range Picker?

For example:

['22/07/2016', '26/07/2016', '29/07/2016']




Thank

Answer

You can use isInvalidDate function.

For example disable Sundays and Saturdays:

isInvalidDate: function(date) {
  return (date.day() == 0 || date.day() == 6);
}

Or disable specific date:

isInvalidDate: function(date) {
    if (date.format('YYYY-MM-DD') == '2016-08-01') {
        return true; 
    } else {
        return false; 
    }
}