disable past dates on datepicker

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

    To disable all previous dates, give start date as today date

    startDate: new Date()
    

    Solution: disable all previous dates from today

    $(function() {
        $( "#datepicker" ).datepicker({ startDate: new Date()});
     });
    
    
    
    
    
    Select Date

    Solution: disable all past dates from a particular date.

    $(function() {
        $( "#datepicker" ).datepicker({ startDate: new Date("2019-10-15")});
    });
    
    
    
    
    
    Select Date

    This will disable all days before the date 15th October 2019 (2019-10-15)

提交回复
热议问题