2

I am using daterangepicker for selecting dates for scheduling a calendar for employees. Now as office is 5days working, So we need to exclude weekends i.e saturday and sunday from selective dates.

Here is what I am using now :

http://www.daterangepicker.com/#options

I have use datelimit function to select only 30days difference

$('#reportrange').daterangepicker({
        ranges: {
            'Today': [moment(), moment()],
            'Next 7 Days': [moment(), moment().add(6, 'days')],
            'Next Month': [moment().add(1, 'month').startOf('month'), moment().add(1, 'month').endOf('month')]
        },
        minDate: new Date(),
        dateLimit: {
            days: '30'
        }
    }, cb);

Please help me to exclude weekends if user chooses one complete month like from 1 January to 31Jaunary. I need weekdays date only.

Ankit
  • 21
  • 2

1 Answers1

0

You can add this function to isInvalidDate option:

isInvalidDate: function(date) {
    if (date.day() == 0 || date.day() == 6) {
        return true;
    } else {
        return false;
    }
}

If you have an another week start day you must change day number like you wish.

Mert S. Kaplan
  • 1,045
  • 11
  • 16