disable past dates on datepicker

前端 未结 22 1272
梦毁少年i
梦毁少年i 2020-11-29 06:03

How to disable past dates from the current date on a datetimepicker? I tried few posts for similar question but was unable to achieve it, Below is what I tried



        
22条回答
  •  庸人自扰
    2020-11-29 06:37

    Note: This scripts works when you're using the daterangepicker library. If you want to disable the Sat or Sunday date on daterangepicker then put this line of code.

            $("#event_start").daterangepicker({
                // minDate: new Date(),
                minYear: 2000,
                showDropdowns: true,
                singleDatePicker: true,
                timePicker: true,
                timePicker24Hour: false,
                timePickerIncrement: 15,
                drops:"up",
                isInvalidDate: function(date) {
                    //return true if date is sunday or saturday
                    return (date.day() == 0 || date.day() == 6);
                },
                locale: {
                    format: 'MM/DD/YYYY hh:mm A'
                }
            });
    

    OR if you want to disable the previous date also with sat and sun then uncomment the this line minDate: new Date()

提交回复
热议问题