JSFiddle - React, Tailwind, and code Playground
by cmruser
HTML
<input type="text" id="datepicker" name="date" />
<p id="data"></p>
JavaScript
$('#datepicker').datepicker({
onSelect: function () {
//$(this).attr('value', $(this).val());
//alert($(this).val());
},
onClose: function(dateText, inst) {
try {
$.datepicker.parseDate('dd/mm/yy', dateText);
} catch (e) {
//alert(e);
};
}
}).on("change", function() {
// regular expression to match required date format
re = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
if($(this).val() != '' && !$(this).val().match(re)) {
alert("Invalid date format: " + $(this).val());
}
});