$( "#checkin" , "#checkout" ).datepicker({
dateFormat: 'mm/dd/yy' ,
firstDay: 1 ,
numberOfMonths: 1 ,
showButtonPanel: false ,
minDate: new Date (),
beforeShow: function (input, obj) {
// code to update calendar availability using backend data
// add classes to td tags to block/disable dates
// NOTE: no AJAX here, calendar data is available for required months
},
onSelect: function (date, inst){
//nothing much here
// few flags for later processing and some code to handle touch devices
},
onClose: function (dateText, inst) {
// code to handle validations of user selection
// set focus on checkin/checkout textboxes deepending on few conditions
},
onChangeMonthYear: function (year, month, inst){
// code to update availability of calendar when user clicks on next/prev month buttons
// update classes of td tags in date picker div to disable/block dates
}
});
....
<div class = "checkin" >
<label> Check - In </label>
<input id= "checkin" class = "hasDatepicker" type= "text" placeholder= "mm/dd/yyyy" autocomplete= "off" >
</div>
<div class = "checkout" >
<label> Check - Out </label>
<input id= "checkout" class = "hasDatepicker" type= "text" placeholder= "mm/dd/yyyy" autocomplete= "off" >
</div>
...
Above code works fine when user interacts with datepicker via mouse but as soon as user start typing into textboxes, the datepicker shows up, date entered by user is highlighted in calendar (which is fine) but all blocked dates are enabled (classes of all td tags in calendar is set to " ") and entire feature is broken.