How to disable past dates from the current date on a datetimepicker? I tried few posts for similar question but was unable to achieve it, Below is what I tried
try this,
$( "#datepicker" ).datepicker({ minDate: new Date()});
Here, new Date() implies today's date....
<div class="input-group date" data-provide="datepicker" data-date-start-date="0d">
<input type="text" class="form-control" id="input_id" name="input_name" />
<div class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</div>
</div>
Problem fixed :)
below is the working code
$(function(){
$('#datepicker').datepicker({
startDate: '-0m'
//endDate: '+2d'
}).on('changeDate', function(ev){
$('#sDate1').text($('#datepicker').data('date'));
$('#datepicker').datepicker('hide');
});
})
minDate: dateToday
Or minDate: '0'
is the key here. Try to set the minDate property.
$(function() {
$( "#datepicker" ).datepicker({
numberOfMonths: 2,
showButtonPanel: true,
minDate: dateToday // minDate: '0' would work too
});
});
Read more
Give zero to mindate
and it'll disabale past dates.
$( "#datepicker" ).datepicker({ minDate: 0});
here is a Live fiddle working example http://jsfiddle.net/mayooresan/ZL2Bc/
The official documentation is available here
Try this,
$("#datetimepicker2").datepicker({ startDate: "+0d" });