Limit end date according to start date on bootstrap-datepicker

Asked

Viewed 554 times

-1

I would like to know how to limit the final date of the form using datepicker, I need that when the initial date is selected in the calendar, the final automatically limit up to 90 days. I have already searched and I haven’t found anything like it. Follow below my html fields:

<div class="row">   
    <div class="input-group date dataIni" data-provide="datepicker">
        <input type="date" class="form-control inputIni">
        <div class="input-group-addon">
            <span class="glyphicon glyphicon-th"></span>
        </div>
    </div>
    <div class="input-group date dataFim" data-provide="datepicker">
        <input type="date" class="form-control inputFim">
        <div class="input-group-addon">
            <span class="glyphicon glyphicon-th"></span>
        </div>
    </div>
</div>

Calendars work correctly, the format has to be dd/mm/yyyy.

1 answer

0

$('inputIni').datetimepicker({
  locale: 'pt-br',
  format: 'DD/MM/YYYY'
});

$('.inputFim').datetimepicker({
  locale: 'pt-br',
  format: 'DD/MM/YYYY',
  useCurrent: false
});

$(".inputIni").on("dp.change", function (e) {
   $('.inputFim').data("DateTimePicker").maxDate(e.date.add(90,'days'));
});
  • Thank you for your help, but in my case I am using the Bootstrap datepicker (https://bootstrap-datepicker.readthedocs.io/en/latest/). I tried to change the parameters using your example but did not give anything. :(

Browser other questions tagged

You are not signed in. Login or sign up in order to post.