Suzan
Suzan

Reputation: 85

Disable all next mondays EXCEPT the next one

I want to disable all next Mondays from jQuery datepicker except the one.

My actual code just disable all next Mondays :

function DisableDates(d) {
    var day = d.getDay();
    return [(day != 0)];
}

http://jsfiddle.net/infinityweb/q48pawj6/10/

Upvotes: 0

Views: 113

Answers (1)

User863
User863

Reputation: 20039

Here is an working example

http://jsfiddle.net/aswinkumar863/dsyk7ah0/

function DisableDates(d) {
  var day = d.getDay();
  var monday = new Date()
  monday.setHours(0, 0, 0, 0)
  monday.setDate(monday.getDate() + (1 + 7 - monday.getDay()) % 7)
  return [(monday.getTime() == d.getTime() || day != 1)];
}

$('#single-listing-date-range').datepicker({
  minDate: +1,
  beforeShowDay: DisableDates
});

Upvotes: 2

Related Questions