longbill/jquery-date-range-picker

Select other dates even there are disabled date in the middle of desired dates

windchime18 opened this issue · 5 comments

Is it possible to select dates between a disabled date? I tried to disable a specific date. e.g. (2018-08-17). I still want to select dates from 2018-08-16 to 2018-08-18.

function pad(number, length) {
   
                var str = '' + number;
                while (str.length < length) {
                    str = '0' + str;
                }
            
                return str;

            }
beforeShowDay: function(t)
                {
                    $dates = '2018-08-17';
                    $calendar_date = t.getFullYear()+"-"+(pad(t.getMonth()+1, 2))+"-"+pad(t.getDate(), 2);
                    var valid = !($calendar_date == $dates);
                    var _class = valid ? '' : 'invalid';
                    var _tooltip = valid ? '' : 'This is already taken.';
                    return [valid,_class,_tooltip];
                },

mm, it seems this is possible, have a look at #352

closing for now

Hello Sir, it seems that the solution doesn't match with my problem. Please check the link containing my sample image for date select.

date range

You can see there that the red shaded date has an "invalid" class. This cannot be selected. but i still wanted to select the next day.

Disabled date: August 17, 2018.

Desired date range to select: August 15 to 18, 2018.

@windchime18 thanks for the screenshot, that helps understanding your case! Indeed, I think by default this is not supported.

When looking at example#26 at https://longbill.github.io/jquery-date-range-picker/ this does also not work by default.

But it seems it is possible, please see this comment #352 (comment), it refers to this example: https://jsfiddle.net/maximelafarie/dnbd01do/21/

In that example the Sundays are disabled, but I can easily select a range from Friday to Monday...

Does this help you?

Thanks a lot. this worked for me

Credits go to @maximelafarie !

Maybe this functionality can be adopted in the library, a Pull Request would be welcome.