I have an array of objects, what is the best way to determine if a date is in the array so it cannot be selected in the jQuery date picker. If needed, I can store DateValue as a date.
var EventDates = [{"DateID: "1", DateValue: "3/1/2011", FormattedDate: Tue, Mar 1 2011"},
{"DateID: "2", DateValue: "3/2/2011", FormattedDate: Wed, Mar 2 2011"}]
$('.juidateicon_ext').datepicker({
showOn: "button",
buttonImage: "/Content/images/icons/calendar.gif",
buttonImageOnly: true,
showOn: 'both',
beforeShowDay: eventDays
});
function eventDays(date) {
1. Code to determine if "date" is in DateValue in the EventDates Array
2. If date exist, return [false, ""];else return [true, ""];
}
I took the liberty of cleaning up your
EventDatesarray:And here’s the
eventDaysfunction:Here’s a working example: http://jsfiddle.net/andrewwhitaker/uYpnW/1/
Hope that helps!