1

I want to disable past dates from the datepicker using bootstrab 2.3.2. I have tried the following code taken from documents, but now i am still battling with this concept. Can anyone give me some ideas? What is wrong with my code?

<div class="input-append date" data-date-format="dd-mm-yyyy" > <input name="date_pick" id="dpd1" type="text" required style="padding:8px 0 !important"> <span class="add-on"><i class="icon-calendar sh_black_text"></i></span> </div> 

My Script

$(function(){ $('.date').datepicker({}); var nowTemp = new Date(); var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0); var checkin = $('#dpd1').datepicker({ onRender: function(date) { return date.valueOf() < now.valueOf() ? 'disabled' : ''; } }) }); 
2

1 Answer 1

1

You must create a new date object and set it as startDate when you initialize the datepickers

Refer this https://bootstrap-datepicker.readthedocs.org/en/release/options.html#startdate

In your case it is

$('.date').datepicker({ startDate: '-1d' }) 

like this

Sign up to request clarification or add additional context in comments.

1 Comment

@UdayaRavi -- I am seeing this line $('.date').datepicker({}); in your sample code. Please update it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.