133
Views
2
Comments
[DateRangePicker] Can i make some dates unselectable?
Question
daterangepicker
Web icon
Forge asset by Niels Favreau

I'm creating a system with date range picker i wanna make a list of dates unselectable, is this possible?

2021-07-14 09-27-33
Luís Cardoso

Frankley Gustavo Fernandes Mesquita wrote:

I'm creating a system with date range picker i wanna make a list of dates unselectable, is this possible?

Hello, 

When you try to that you need to define a Start Date and End Date to analyze that period of time, right?

After that you can filter and remove from that list the dates that are selected. That looks OK to you?




2022-07-07 18-45-50
Niels Favreau

Currently the component don't provide that functionality, since it was not a feature in the documentation from the JS library.
When i took a look at the github on how to achieve this you will need to extend the component with the folowing parameter added:

The isInvalidDate setting allows you to disable dates on the calendars. You provide a function and it is passed each date in the calendar. Return true if it should be disabled.

$('#yourelement').daterangepicker({
  isInvalidDate: function(date) {
    //compare to your list of dates, return true if date is in the list
  }
});


I will add this in the future to the component whenever i have time, since it's quite a good feature to have.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.