How do I only enable the last days of months with Datepicker Jquery?

datepicker, javascript, jquery, jquery-ui

Solution

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, ''];
    }
});

Problem

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 ?

Original source