I’m having trouble with a datepicker that I have created. I am using a very similar datepicker on the same page with no issue at all. The date picker shows with no selectable days, even though when I debug the ‘limitToOneYear’ function, it is returning true for some days. Am I missing something simple and obvious?
function limitToOneYear(date) {
var thisdate = Date.parse(date);
var now = new Date();
var today = Date.parse(new Date(now.getFullYear(),now.getMonth(),now.getDate()));
var maxDate = Date.parse(new Date((now.getFullYear() + 1), now.getMonth(), now.getDate()));
return (thisdate >= today && thisdate < maxDate);
}
$(".expirationDate").datepicker({
showOn: 'both',
buttonImage: '/images/datepicker/button.gif',
buttonImageOnly: true,
beforeShowDay: limitToOneYear
});
Should you not be returning an array from your limitToOneYear function as per the DatePicker API for beforeShowDay
So your limitToOneYear function should be something like this