How do I disable past dates on jQuery datepicker? I looked for options but don\'t seem to find anything that indicates the ability to disable past dates.
UPDATE: Th
You just need to specify a minimum date - setting it to 0 means that the minimum date is 0 days from today i.e. today. You could pass the string '0d'
instead (the default unit is days).
$(function () {
$('#date').datepicker({ minDate: 0 });
});
This should work <input type="text" id="datepicker">
var dateToday = new Date();
$("#datepicker").datepicker({
minDate: dateToday,
onSelect: function(selectedDate) {
var option = this.id == "datepicker" ? "minDate" : "maxDate",
instance = $(this).data("datepicker"),
date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.not(this).datepicker("option", option, date);
}
});
//disable future dates
$('#datetimepicker1').datetimepicker({
format: 'DD-MM-YYYY',
maxDate: new Date
});
//disable past dates
$('#datetimepicker2').datetimepicker({
format: 'DD-MM-YYYY',
minDate: new Date
});