简体   繁体   中英

Disable Past Dates in Metronic Template datetimepicker plugin

I'm using Metronic Template in my Laravel project. Here I wanted to disable past dates in datetime picker plugin. I have searched some blogs and most answers were to use minDate:0 property. But it seems this doesn't work in Metronic template. Please help me if you have experience in such case. Here is my code.

<div class="input-group date">
  <input type="text" class="form-control m-input" readonly="" name="followup_deadline" placeholder="Select date &amp; time" id="datePicker">
  <div class="input-group-append">
    <span class="input-group-text">
      <i class="la la-calendar-check-o glyphicon-th"></i>
    </span>
  </div>
</div>

And javascript/jquery code is here

$("#datePicker").datetimepicker({
            todayHighlight: !0,
            autoclose: !0,
            pickerPosition: "bottom-left",
            format: "yyyy-mm-dd hh:ii:00"
        });

Other details needed? Looking forward your kind answer.

Hi I solved it using this format

Javascript

   let todayDate = new Date().getDate();
   let endD = new Date(new Date().setDate(todayDate));
   $('.form_datetime').datetimepicker({
      startDate : endD,
      weekStart: 7,
      todayBtn:  1,
      autoclose: 1,
      todayHighlight: 1,
   });

As you can see I have created a Date object and assigned it to startDate this then will disable all date behind the current date (even the time).

Html

<div class="input-group date form_datetime">
    <input type="text" size="16" id="datee" class="form-control" name="date_needed" required>
    <span class="input-group-btn">
        <button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
    </span>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM