Skip to content Skip to sidebar Skip to footer

Date Range Picker - Invalid Date

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

Solution 1:

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;
    }
  }
}

Solution 2:

You'll need a way to feed the blocked date from your backend to the client. But let's suppose you solved that and have the dates in an array. All you need to do then is to check if the date in in the array.

See e.g. here: Checking if date belongs to array of dates

To get the invalid dates from the backend you could either put them in the script itself, of have the script fetch the to be blocked dates from the server using e.g. ajax.

Don't forget to revalidate on the server, never trust filtering in the clients to actually happen.


Post a Comment for "Date Range Picker - Invalid Date"