How to disable old dates in Bootstrap Datepiker version?

Asked

Viewed 818 times

1

Can not choose the old date. For example: Today is day 18/01/2017, You have to disable 17/01/2017, 16/01/2017 e assim vai ... Can not disable date today and future.

Here is the full code in jquery version :http://jsfiddle.net/yTMwu/216/

How to do this in the version bootstrap datepicker ?

2 answers

2

  • Gabriel Weber, thank you for your reply, I thank you

2


Simple, just use the startDate, as in the example below.

$('input').datepicker({
  autoclose: true,
  startDate: 'd'
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker3.css" rel="stylesheet" />
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.js"></script>

<input type="text" type="text" class="form-control" />

If you want days in the past or future, you can change to startDate: '-5d' or startDate: '+5d', which will put the initial date for 5 days before (-5d) or 5 days after (+5d).

  • Boy, it’s that simple ?

  • 1

    Incredible as it may seem, yes.

Browser other questions tagged

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