Im using Bootstrap DateTimePicker to show a calender, and i want to remove some days from the calender (disable them)
$(function () {
$('#datetimepicker1').datetimepicker({
inline: true,
format: "dd MM yyyy",
defaultDate: null,
disabledDates: function (date) {
var day = date.getDay();
return [(day != 1 && day != 2)];
}
})
}).on('dp.change', function (e, selectedDate, $td) {
//var time = e.date.format("HH:mm:ss");
//alert(e.date + ' - ' + time);
$('.input-field1').val(e.date.format("DD/MM/YYYY"));
if (check) {
$('.FormDownDateSelect').slideToggle("fast", function () { });
}
});
I tried the code above Special the part with DisabledDates but it dont work. Can someone tell me how to disable some days of the week. Sunday to Wednesday.
You could use daysOfWeekDisabled
setting described here.
Your code would look somehow like this:
$(function () {
$('#datetimepicker1').datetimepicker({
inline: true,
format: "dd MM yyyy",
defaultDate: null,
daysOfWeekDisabled: [0, 6]
})
}).on('dp.change', function (e, selectedDate, $td) {
//var time = e.date.format("HH:mm:ss");
//alert(e.date + ' - ' + time);
$('.input-field1').val(e.date.format("DD/MM/YYYY"));
if (check) {
$('.FormDownDateSelect').slideToggle("fast", function () { });
}
});