Menaka Kariyawasam Menaka Kariyawasam - 1 month ago 16
jQuery Question

How to disable past dates in Bootstrap datetimepicker after set check in date

I know how to disable past days from current date.
its working with jsfiddle

but my problem is how can I disable previous dates after select

check in
date.

my jquery

$(function () {

$('#datetimepicker1').datetimepicker({
format: 'YYYY-MM-DD'
});
$('#datetimepicker2').datetimepicker({
format: 'YYYY-MM-DD'
});
$('#from_date').datetimepicker({
format: 'YYYY-MM-DD'
});
$('#to_date').datetimepicker({
format: 'YYYY-MM-DD'
});
});


my view

<div class='col-md-offset-2 col-sm-3 col-xs-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker1'>
<input type='text' name="from_date" id="from_date" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>

<div class='col-sm-3 col-xs-6'>
<div class="form-group">
<div class='input-group date' id='datetimepicker2'>
<input type='text' name="to_date" id="to_date" class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>

<div class='col-sm-1 col-xs-12'>
<button class="btn btn-info" id="search">SEARCH</button>
</div>


enter image description here
any help please.

Answer

Have you tried like this

$('#datetimepicker').datetimepicker({  minDate:new Date('2016-10-25')}); //set check in date here

EDIT

For Format date

$('#datetimepicker').datetimepicker({  
    format: 'YYYY-MM-DD',
    minDate:new Date('2016-10-25')
});
Comments