JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/themes/cupertino/jquery-ui.cs"></script>
<input type="text" id="datepicker" class="form-control" autocomplete="off">
JavaScript
$("#datepicker").datepicker({
dateFormat: "dd.mm.yy",
minDate: 0,
maxDate: "1years",
changeMonth: true,
changeYear: true,
onSelect: function(date_text,inst)
{
var from = new Date(date_text);
$( "#datepicker" ).datepicker( "option", "minDate",from);
/*
$.ajax({
type: "POST",
dataType: "json",
url: {link do!},
data: { color: $('#datepicker').val(), time: $('#time').val() },
success:function(data) {
},
});
*/
}
}).datepicker("setDate", {$datum});
// validate date
$("#datepicker").datepicker();
var previousDate;
$("#datepicker").focus(function(){
previousDate= $(this).val(); ;
});
$("#datepicker").blur(function(){
var newDate = $(this).val();
if (!moment(newDate, 'DD.MM.YYYY', true).isValid()){
$(this).val(previousDate);
console.log("Error");
}
});
// disable manual beforeDay
var dateToday = new Date();
$("#datepicker").change(function () {
var updatedDate = $(this).val();
var instance = $(this).data("datepicker");
var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, updatedDate, instance.settings);
if (date < dateToday) {
$(this).datepicker("setDate", dateToday);
}
});