Created
August 3, 2012 16:52
-
-
Save stevesmename/3249436 to your computer and use it in GitHub Desktop.
Special params that set min/max dates with date_popup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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