Check Datepicker für MaxDate
by Bianca Kuehweidner
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css">
<input class="datepicker">
CSS
body {
font: 12px sans-serif;
}
JavaScript
$(document).ready(function() {
$(".datepicker").attr("placeholder", "dd.mm.yyyy").datepicker({
dateFormat: "dd.mm.yy",
maxDate: "+1",
showOn: "button",
showOtherMonths: true
}).on("change", function(e) {
var curDate = $(this).datepicker("getDate");
var maxDate = new Date();
maxDate.setDate(maxDate.getDate() + 1); // add one day
maxDate.setHours(0, 0, 0, 0); // clear time portion for correct results
console.log(this.value, curDate, maxDate);
if (curDate > maxDate) {
alert("invalid date");
$(this).datepicker("setDate", maxDate);
}
});
});