Answers for "bootstrap-datepicker disable dates from another month"

0

bootstrap-datepicker disable dates from another month

// link for issue
// https://github.com/Eonasdan/bootstrap-datetimepicker/issues/2077

//1 - Create these functions in a custom (DatePicker) namespace.
DatePicker = {
        hideOldDays: function(){ // hide days for previous month
            var x = $('.datepicker .datepicker-days tr td.old');
            if(x.length > 0){
                x.css('visibility', 'hidden');
                if(x.length === 7){
                    x.parent().hide();
                }
            }
        },
        hideNewDays: function(){ // hide days for next month
            var x = $('.datepicker .datepicker-days tr td.new');
            if(x.length > 0){
                x.hide();
            }
        },
        hideOtherMonthDays: function(){ // hide days not for current month
            DatePicker.hideOldDays();
            DatePicker.hideNewDays();
        }
    };
    
//2 - Add this event for datePicker
$('.datepicker').datepicker().on('show', function(e) {
        DatePicker.hideOtherMonthDays();
    });
Posted by: Guest on April-10-2020

Code answers related to "bootstrap-datepicker disable dates from another month"

Code answers related to "Javascript"

Browse Popular Code Answers by Language