JSFiddle - React, Tailwind, and code Playground
by Mohit Kumar Gupta
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", "mm-dd-yyyy").datepicker({
dateFormat: "mm-dd-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);
}
});
});