So my question is pretty simple. I'd like to have specific dates that are enabled on a datepicker, like this http://tokenposts.blogspot.fr/2011/05/jquery-datepicker-disable-specific.html but I only want the last day of any month, for example 30/06/2012, 31/07/2012, ...
Any clue ?
This is how you can do it...
Getting the last day for a given year and month:
function getLastDayOfYearAndMonth(year, month)
{
return(new Date((new Date(year, month + 1, 1)) - 1)).getDate();
}
Check with beforeShowDay
event if date is the last month day:
$('.selector').datepicker(
{
beforeShowDay: function(date)
{
// getDate() returns the day [ 0 to 31 ]
if (date.getDate() ==
getLastDayOfYearAndMonth(date.getFullYear(), date.getMonth()))
{
return [true, ''];
}
return [false, ''];
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With