Skip to content

Instantly share code, notes, and snippets.

@stevesmename
Created August 3, 2012 16:52
Show Gist options
  • Save stevesmename/3249436 to your computer and use it in GitHub Desktop.
Save stevesmename/3249436 to your computer and use it in GitHub Desktop.
Special params that set min/max dates with date_popup
(function($) {
$(document).ready(function() {
var hotel_dates = $( "#hotel-checkin, #hotel-checkout" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: "mm/dd/yy",
autoSize: true,
onSelect: function( selectedDate ) {
var option = this.id == "hotel-checkin" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
hotel_dates.not( this ).datepicker( "option", option, date );
$("#hotel-checkout").val(selectedDate);
}
});
var air_dates = $( "#air-depart, #air-return" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: "mm/dd/yy",
autoSize: true,
onSelect: function( selectedDate ) {
var option = this.id == "air-depart" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
air_dates.not( this ).datepicker( "option", option, date );
$("#air-return").val(selectedDate);
}
});
var car_dates = $( "#car-depart, #car-return" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
dateFormat: "mm/dd/yy",
autoSize: true,
onSelect: function( selectedDate ) {
var option = this.id == "car-depart" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
car_dates.not( this ).datepicker( "option", option, date );
$("#car-return").val(selectedDate);
}
});
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment