I am trying to only allow the first Friday of every month to be selectable in my jQuery UI Datepicker and deny any other date.
I realise I could do this with a combination of PHP and jQuery by getting the date of the first Friday for X months in the future, then adding them to a javascript array that I check against within Datepicker's beforeShowDay
- something like this:
var allowedDates = new Array();
allowedDates[] = <?=date("d/m/Y",strtotime("first Friday of February 2012"))?>
allowedDates[] = <?=date("d/m/Y",strtotime("first Friday of March 2012"))?>
allowedDates[] = <?=date("d/m/Y",strtotime("first Friday of April 2012"))?>
(I would of course put this in a for loop rather than typing each month manually)
The problem with this is that it is limiting due to me having to specify how far in the future to look. So is there a way with javascript to check to see if the date checked in Datepicker's beforeShowDay
is the first of the month without me having to specify how far into the future to check?
Thanks!