disable past dates on datepicker

前端 未结 22 1271
梦毁少年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:30

    you have just introduce parameter startDate as mentioned below.

    var todaydate = new Date();
        $(".leave-day").datepicker({
            autoclose: true,
            todayBtn: "linked",
            todayHighlight: true,
            startDate: todaydate     
          }
        ).on('changeDate', function (e) {
            var dateCalendar = e.format();
            dateCalendar = moment(dateCalendar, 'MM/DD/YYYY').format('YYYY-MM-DD');
            $("#date-leave").val(dateCalendar);
        });
    

提交回复
热议问题