Date range picker - invalid date

Domagoj Rogošić picture Domagoj Rogošić · Nov 22, 2015 · Viewed 12k times · Source

I am using this date range picke (http://www.daterangepicker.com/#options)

Here are some of options, I understand the most but I need help about "isInvalidDate"

I use this code and it works perfectly. Date 11/12/2015 is disabled and users can't select it.

isInvalidDate: function(date) {
    if (date.format('YYYY-MM-DD') == '2015-11-12') {
        return true; 
    } else {
        return false; 
    }
},

But I need to add few dates to invalid, so user can't use them. I don't know how to do some array and loop through to return true or false days, could anyone help me with this?

Answer

Aleskei Sakharov picture Aleskei Sakharov · Apr 1, 2016

I hope it will help someone

 var some_date_range = [
  '02-04-2016',
  '03-04-2016',
  '04-04-2016',
  '05-04-2016'
];
"isInvalidDate" : function(date){
  for(var ii = 0; ii < some_date_range.length; ii++){
    if (date.format('DD-MM-YYYY') == some_date_range[ii]){
      return true;
    }
  }
}