Search code examples
javascriptdatepickerbootstrap-datepicker

when datepicker class is used in input field, bootstrap datepicker (autoclose,endDate,startDate) doesn't work


the following code is not working if I add datepicker in the input field class

JS

$(document).ready(function () {
  $("#ActionDateInput").datepicker({
    autoclose: true,
    endDate: new Date()
  });
});            

HTML

<input type="text" id="ActionDateInput" class="datepicker form-control" placeholder="Date" name="date" autocomplete="off"/>

But if I remove datepicker from the class, it works.
HTML

<input type="text" id="ActionDateInput" class="form-control" placeholder="Date" name="date" autocomplete="off"/>

I want to keep the datepicker in the class for design purpose. I used bootstrap-datepicker

<script src="${contextPath}/resources/asset/js/bootstrap-datepicker.js"></script> 

Solution

  • Try it:

     $("#ActionDateInput").datepicker().datepicker("setEndDate",new Date());