Bootstrap datepicker disabling past dates without current date

前端 未结 20 2098
[愿得一人]
[愿得一人] 2020-11-27 04:55

I wanted to disable all past date before current date, not with current date. I am trying by bootstrap datepicker library \"bootstrap-datepicker\" and using following code:<

相关标签:
20条回答
  • 2020-11-27 05:45

    In html

    <input class="required form-control" id="d_start_date" name="d_start_date" type="text" value="">
    

    In Js side

    <script type="text/javascript">
            $(document).ready(function () {
            var dateToday = new Date();
            dateToday.setDate(dateToday.getDate());
    
            $('#d_start_date').datepicker({
                autoclose: true,
                startDate: dateToday
            })
    
        });
    
    0 讨论(0)
  • 2020-11-27 05:47

    HTML

    <input type="text" name="my_date" value="4/26/2015" class="datepicker">
    

    JS

    jQuery(function() {
      var datepicker = $('input.datepicker');
    
      if (datepicker.length > 0) {
        datepicker.datepicker({
          format: "mm/dd/yyyy",
          startDate: new Date()
        });
      }
    });
    

    That will highlight the default date as 4/26/2015 (Apr 26, 2015) in the calendar when opened and disable all the dates before current date.

    0 讨论(0)
提交回复
热议问题