0

How to Restrict to choose the future date in Bootstrap Date picker?

here is the code what i tried

 $( 'selecter' ).datepicker( { maxDate : new Date(), autoclose : true } ); 
2

2 Answers 2

1

I use this on my code :

$('.disable-past-date-picker').datepicker({ format: 'dd-mm-yyyy', onRender: function(date) { return date.valueOf() < now.valueOf() ? 'disabled' : ''; } }); 
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to restrict the datepicker to only allow the selection of dates in the future, use the following:

 $('.datepicker').datepicker({ startDate: new Date() }); 

To only allow dates in the past, use this instead:

 $('.datepicker').datepicker({ endDate: new Date() }); 

Fiddle here: http://jsfiddle.net/tuG6C/620/

3 Comments

I tried these code but not working. I am using Bootstrap date picker not the jQuery date picker.
Hi John, there is no DatePicker included with Bootstrap by default, do you mean this one: github.com/eternicode/bootstrap-datepicker Are you getting any errors in your console?
Great! That's the one I used in the fiddle. Did you look at that? How exactly is yours "not working"?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.