Skip to content

Instantly share code, notes, and snippets.

@rilwis
Forked from kutoi94/custom.js
Last active January 31, 2020 09:11
Show Gist options
  • Save rilwis/b7836dfac1300ade67b3da9555ef5bab to your computer and use it in GitHub Desktop.
Save rilwis/b7836dfac1300ade67b3da9555ef5bab to your computer and use it in GitHub Desktop.
How to Build a Hotel Booking Website Using Meta Box (P3)
jQuery( function($) {
setTimeout(function(){
datepicker_reinstall();
console.log(disable_dates);
}, 1000);
function datepicker_reinstall(){
var dateFormat = "yy-mm-dd",
from = $( "#group_booking_check_in" ),
to = $( "#group_booking_check_out" );
from.add(to).datepicker('destroy');
from.datepicker({
minDate: 0,
defaultDate: "+1w",
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ disable_dates.indexOf(string) == -1 ]
}
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
});
to.datepicker({
defaultDate: "+1w",
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ disable_dates.indexOf(string) == -1 ]
}
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dateFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment