datepicker - set minDate of second datepicker on selection changed on date picker 1

datepicker - set minDate of second datepicker on selection changed on date picker 1

Hi,

I have two date pickers, when the first date picker has its value changed, I want the minDate variable on the second date picker to be updated to be datepicker1 + 1 day.

My code isn't working since I added the minDate line, can someone point out where I went wrong?

  1. $("#arrivaldate").datepicker({
  2. showOn: 'button',
  3. buttonImage: 'images/calendar.gif',
  4. dateFormat: 'dd M yy',
  5. numberOfMonths: 3,
  6. minDate: 0,
  7. onSelect: function(dateStr) {
  8.      var newDate = $(this).datepicker('getDate');
  9.      if (newDate) { // Not null
  10.              newDate.setDate(newDate.getDate() + 1);
  11.      }
  12.      $('#departuredate').datepicker('setDate', newDate);
  13.      $('#departuredate').datepicker('minDate', newDate);     
  14. },
  15. constrainInput: true,
  16. buttonImageOnly: true
  17. });