0

I'm working on a hotel website, complete with reservation tool and I need to make one last change to the integrated datepicker.

Currently the code has been modified to allow for Saturday check-ins only.

I need to make a further modification to enable only April, May, June, July, August, September.

Can anybody show me how to add a getMonth to this existing code to achieve the above?

Here is the existing:

    $.fn.gdlr_datepicker = function(){
    $(this).datepicker({
        dateFormat : 'yy-mm-dd',
        minDate: 0,




        changeMonth: true,
        changeYear: true,
        closeText: objectL10n.closeText,
        currentText: objectL10n.currentText,
        monthNames: objectL10n.monthNames,
        monthNamesShort: objectL10n.monthNamesShort,
        dayNames: objectL10n.dayNames,
        dayNamesShort: objectL10n.dayNamesShort,
        dayNamesMin: objectL10n.dayNamesMin,
        firstDay: objectL10n.firstDay,

    beforeShowDay: function(date) {

        var date1 = $.datepicker.parseDate('yy-mm-dd', $("#gdlr-check-in").val());
        var date2 = $.datepicker.parseDate('yy-mm-dd', $("#gdlr-check-out").val());
        return [date.getDay() === 6, date1 && ((date.getTime() == date1.getTime()) || (date2 && date >= date1 && date <= date2)) ? "dp-highlight" : ""];
        },

    });

Thanks in advance.

1 Answers1

0

You should add an array with your months and then add a check in the return statement

monthArray = [3, 4, 5, 6, 7, 8];
 $.fn.gdlr_datepicker = function(){
        $(this).datepicker({
            dateFormat : 'yy-mm-dd',
            minDate: 0,




            changeMonth: true,
            changeYear: true,
            closeText: objectL10n.closeText,
            currentText: objectL10n.currentText,
            monthNames: objectL10n.monthNames,
            monthNamesShort: objectL10n.monthNamesShort,
            dayNames: objectL10n.dayNames,
            dayNamesShort: objectL10n.dayNamesShort,
            dayNamesMin: objectL10n.dayNamesMin,
            firstDay: objectL10n.firstDay,

        beforeShowDay: function(date) {

            var date1 = $.datepicker.parseDate('yy-mm-dd', $("#gdlr-check-in").val());
            var date2 = $.datepicker.parseDate('yy-mm-dd', $("#gdlr-check-out").val());
            return [$.inArray(date.getMonth(), monthArray) > -1 && date.getDay() === 6, date1 && ((date.getTime() == date1.getTime()) || (date2 && date >= date1 && date <= date2)) ? "dp-highlight" : ""];
            },

        });
calinaadi
  • 1,466
  • 1
  • 13
  • 22