Reputation: 3
I have a function that hides the days of the weeks datepicker. Need, in addition to this, hide specific days ... Ex: "09/09/2014", "10/10/2014"
This is my jquery ...
jQuery("#wpsc_checkout_form_9998").datepicker(
"option",
"beforeShowDay",
function(date) {
var day = date.getDay();
return [(day != 4) && (day != 2), ''];
}
);
Upvotes: 0
Views: 2992
Reputation: 11416
Create an array of the days you want to exclude and add checking for them in the beforeShowDay
option:
$(document).ready(function () {
var arrDisabledDates = {};
arrDisabledDates[new Date('08/08/2014')] = new Date('08/08/2014');
arrDisabledDates[new Date('08/30/2014')] = new Date('08/30/2014');
$('#txtDate').datepicker({
beforeShowDay: function (date) {
var day = date.getDay(),
bDisable = arrDisabledDates[date];
if (bDisable) return [false, '', '']
else return [(day != 4) && (day != 2)];
}
});
});
Find Demo here: jQuery Datepicker excluding specific dates and days
This is an adjusted version of an example for excluding specific dates I just found here: http://www.jquerybyexample.net/2013/03/hide-disable-dates-in-jquery-ui-datepicker.html
Upvotes: 3