0

I have two date pickers (arrival date and depart date) the user selects an arrival date and then, when the user selects a depart date it must disable (or grey out) all previous dates from which the arrival date has been chosen, i.e if arrival date is 4th July 2013, user can only select a depart date from 4th July 2013 and onwards.

I have used the following code to no success:

<script>
jQuery(function($){
$( "#input_2_5" ).datepicker({
  onClose: function( selectedDate ) {
    $( "#input_2_6" ).datepicker( "option", "minDate", selectedDate );
  }
});
$( "#input_2_6" ).datepicker({
   onClose: function( selectedDate ) {
    $( "#input_2_5" ).datepicker( "option", "maxDate", selectedDate );
   }
});
</script>
4

1 回答 1

0

你通常会这样做:

$("#from_date").datepicker({
    minDate   : 0,
    onSelect: function() {
        var minDate = $(this).datepicker('getDate');
        minDate.setDate(minDate.getDate());
        $("#to_date").datepicker( "option", "minDate", minDate);
    }
});

$("#to_date").datepicker({
    minDate: 0
});

小提琴

于 2013-07-03T20:35:27.173 回答