views:

499

answers:

1

Hi all, jquery datepicker is a great fun but I am facing a weird error. I am trying to disable some days, ie. 28 October 2009 but 28 November gets disabled on the calendar! Any idea what I am doing wrong here? The disabledDays array variable is a script registered on the server as the closing dates come from database.

<script type="text/javascript">

    $(document).ready(function() {
        $("#datepicker").datepicker(
            {
                dateFormat: 'dd/mm/yy',
                changeYear: false,
                yearRange: '0:+1',
                numberOfMonths: 2,
                firstDay: 1,
                minDate: '0',
                maxDate: '+2m',
                altFormat: 'dd/mm/yy',
                beforeShowDay: DisableClosedDays
            });
    });


    function DisableClosedDays(calendarDate) {
        for (i = 0; i < disabledDays.length; i++) {
            if (calendarDate.getDate() == disabledDays[i][0]
            && calendarDate.getMonth() == disabledDays[i][1]
            && calendarDate.getFullYear() == disabledDays[i][2]) {
                return [false, ''];
            }
        }
        return [true, ''];
    }
</script>





<script type="text/javascript"> 
//<![CDATA[
var disabledDays = [[22,10,2009],[30,10,2009],[12,10,2009]];
//]]>
</script>
+2  A: 

Months in Javascript run from 0-11 not 1-12.

Greg
Thanks, I didn't know that.
David