Jump to content

jquery datepicker problem


zimmo

Recommended Posts

I am trying to extend my plug in by restricting the sunday from the calendar. I am not sure how to do this with my existing code.

 

here is the code which is currently not working:

 

<script type="text/javascript">

$(function() {

// Tabs

$('#datepicker1').datepicker({

beforeShowDay: function(date) {

return [(date.getDay() > 1), ""];

}

minDate: 0,

maxDate: "+12M +0D",

dateFormat: 'dd-mm-yy'

});

});

</script>

 

Can anyone see anything obvious??

 

Thanks

Barry

Link to comment
https://forums.phpfreaks.com/topic/215317-jquery-datepicker-problem/
Share on other sites

I have been searching google and have found some code where people have managed to do this. The code below works great now, I can specify holidays etc.. that are closed and also sundays being closed.

 

I need to extend this, (not a javascript expert) so that I can specify mothers day and valentines day for delivery as well. Can anyone help me do this????? I need to change this code to allow for specific days that they are OPEN. It only allows closed days.

 


<script type="text/javascript">
$(document).ready(function(){

    $("#datepicker").datepicker({
        beforeShowDay: nonWorkingDates,
        numberOfMonths: 1,
        minDate: '0',
        maxDate: '+12M',
        firstDay: 1
    });

    function nonWorkingDates(date){
        var day = date.getDay(), Sunday = 0, Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6;
        var closedDates = [[7, 29, 2009], [8, 25, 2010]];
        var closedDays = [[sunday]];
        for (var i = 0; i < closedDays.length; i++) {
            if (day == closedDays[i][0]) {
                return [false];
            }

        }

        for (i = 0; i < closedDates.length; i++) {
            if (date.getMonth() == closedDates[i][0] - 1 &&
            date.getDate() == closedDates[i][1] &&
            date.getFullYear() == closedDates[i][2]) {
                return [false];
            }
        }

        return [true];
    }

});
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.