2

I have two calendars on an HTML page defined as:

<p>Calendar 1:
    <input type="text" id="datepicker1" />
</p>
<p>Calendar 2:
    <input type="text" id="datepicker2" />
</p>

I want to disable all Sundays, Mondays and Tuesdays on Calendar 1 and I also want to set the minDate of that calendar to tomorrow.

I also want to make it so that Calendar 2's maxDate should be the date selected in Calendar 1.

ydaetskcoR
  • 53,225
  • 8
  • 158
  • 177
rafat
  • 819
  • 2
  • 10
  • 25
  • Tidied up to make it clearer. The question really needs to be split into two though as well as the OP to add examples of what s/he has tried. – ydaetskcoR Apr 01 '15 at 11:00
  • You can't set a widget option to a pointer, only a specific value: you'll need to update the second datepicker's maxDate in the change-event handler of the first datepicker. As for disabling days of the week, I'm pretty sure [this has been asked and answered already](http://stackoverflow.com/questions/501943/) – blgt Apr 01 '15 at 13:04

1 Answers1

2
  function beforeShowDay(date) {
     var day = date.getDay();
     return [(day != 7 && day != 1 && day != 2)];
}

This code will disable all the sunday,monday and tuesday of your calendar.

$("#datepicker1").datepicker().change(function () {


    $("#datepicker2").datepicker('option', 'maxDate', $(this).datepicker('getDate'));


});

This code will set the 2nd calendars maxDate on the 1st calendars selection.

rafat
  • 819
  • 2
  • 10
  • 25