Code Test Select Date use Jquery

by - July 03, 2014


Datepicker is tied to a standard form input field which allow user click to open an interactive calendar in a small overlay. Implemented Jquery to set min Date and max Date 


<script>
$(function() {
$( "#check_in" ).datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    minDate: 0,
    onClose: function( selectedDate ) {
        var selectedDate = $(this).datepicker('getDate');
            if (selectedDate) {
                  selectedDate.setDate(selectedDate.getDate() + 1);
            }
    $( "#check_out" ).datepicker( "option", "minDate", selectedDate );
    }
    });
$( "#check_out" ).datepicker({
    defaultDate: "+1w",
    changeMonth: true,
    minDate: 0,
    onClose: function( selectedDate ) {
    $( "#check_in" ).datepicker( "option", "maxDate", selectedDate );
    }
    });
});
</script>

You May Also Like

0 comments