disable past dates on datepicker

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

    You can use

    $('#li_from_date').appendDtpicker({
        "dateOnly": true,
        "autodateOnStart": false,
        "dateFormat": "DD/MM/YYYY",
        "closeOnSelected": true,
        "futureonly": true
    });
    
    0 讨论(0)
  • 2020-11-29 06:29

    Below solution worked for me. I hope, this will help you also.

    $(document).ready(function() {
        $("#datepicker").datepicker({ startDate:'+0d' });
    });
    
    0 讨论(0)
  • 2020-11-29 06:29

    Set an end date based on start date using datepicker

      $("#AddEvent_txtStartDate").datepicker({
            onSelect: function () {
                minDate = $("#AddEvent_txtStartDate").datepicker("getDate");
                var mDate = new Date(minDate.setDate(minDate.getDate()));
                $("#AddEvent_txtEndDate").datepicker("setDate", mDate);
                $("#AddEvent_txtEndDate").datepicker("option", "minDate", mDate);
            }
        });  
        $("#AddEvent_txtEndDate").datepicker();
    
    0 讨论(0)
  • 2020-11-29 06:30

    this works for me,

    $('#datetimepicker2').datetimepicker({
        startDate: new Date()
      });
    
    0 讨论(0)
  • 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);
        });
    
    0 讨论(0)
  • $(function () {
        $("#date").datepicker({ minDate: 0 });
    });
    
    0 讨论(0)
提交回复
热议问题