4

I am working with jquery multidatespicker where I have to define a range of dates to be allowed after the first date has been picked.

I need to exclude the weekends from all the future dates. However, pickableRange doesn't skip the weekends that are disabled with beforeShowDay.

I also tried adding addDisabledDates but it is not feasible to add all the weekend dates in an array.

This is the code that I have been trying.

$('#id').multiDatesPicker({
    pickableRange: 15,
    adjustRangeToDisabled: true,
    beforeShowDay:  $.datepicker.noWeekends,
    addDisabledDates : ['array containing all weekends and holidays'] // not feasible option
})

Kindly help me out here..

Sankalp Tambe
  • 400
  • 4
  • 15

1 Answers1

7
$('#id').multiDatesPicker({
  beforeShowDay: disableSpecificWeekDays,
  // For disabling all "Sundays and saturday"
  dateFormat: "d/m/yy",
  maxDate: "+3m",
  minDate: "-1m",
  multidate: true,
});

function disableSpecificWeekDays(date) {
  var theday = date.getDate() + '/' +
      (date.getMonth() + 1) + '/' +date.getFullYear();
  var day = date.getDay();
    return [day != 0 && day != 6];
}

Here we can assign a method for disabling a weekend. please try this.

Sasikala J
  • 526
  • 5
  • 14
  • This is not the answear to the question, should be downvoted. The question clearly states that it doesn't work with autoselected ranges. – KronosL Jan 22 '19 at 18:27
  • @KronosL Thank you for your attention. I have added a possible solution only. I have tried in my way. If you have a better solution kindly please upload it. I too wanna get the best way to do that. – Sasikala J Feb 22 '19 at 05:11