Reputation: 84
Hiii..
My concept is an agent wants add date from backend which is from(6/07/2015) to until(20/07/2015) these dates will store in database. if agent want disable 2 days(ex. 12/07/15 and 14/07/2015) then how to show these dates disable in datepicker on fron end. Because these two day agent haven't product. That's why agent wants these two day disable and remaining day 6 to 20 should be enable.
Please any body have any idea please help me. Thanks!!!
Upvotes: 1
Views: 4204
Reputation: 1903
Bootstrap datepicker:
In the bootstrap datepicker you can use the method:
String, Array. Default: []
Array of date strings or a single date string formatted in the given date format
for example:
$('#sandbox-container input').datepicker({
datesDisabled: ['07/06/2015', '07/21/2015']
});
JQUERY datepicker UI
In this use the beforeShowDay method
var unavailableDates = ["9-5-2011","14-5-2011","15-5-2011"];
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) < 0) {
return [true,"","Book Now"];
} else {
return [false,"","Booked Out"];
}
}
$('#iDate').datepicker({ beforeShowDay: unavailable });
refernce for JQUERY datepicker UI
Upvotes: 0
Reputation: 802
please refer this link. this is working example with jquery datepicker.
Please see below code.
var unavailableDates = ["9-3-2012", "14-3-2012", "15-3-2012"];
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) == -1) {
return [true, ""];
} else {
return [false, "", "Unavailable"];
}
}
$(function() {
$("#iDate").datepicker({
defaultDate: new Date("3-1-2012"),
dateFormat: 'dd MM yy',
beforeShowDay: unavailable
});
});
Upvotes: 2