Date restrict Jquery
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script>
$(function(){
var natDays = [
[1, 1, 'New Year'], //2014
[1, 20, 'Martin Luther King'], //2014
[2, 17, 'Washingtons Birthday'], //2014
[5, 26, 'Memorial Day'], //2014
[7, 4, 'Independence Day'], //2014
[9, 1, 'Labour Day'], //2014
[10, 14, 'Columbus Day'], //2013
[11, 11, 'Veterans Day'], //2013
[11, 28, 'Thanks Giving Day'], //2013
[12, 25, 'Christmas'] //2013
];
// dateMin is the minimum delivery date
var dateMin = new Date();
dateMin.setDate(dateMin.getDate() + (dateMin.getHours() >= 14 ? 1 : 0));
function AddBusinessDays(curdate, weekDaysToAdd) {
var date = new Date(curdate.getTime());
while (weekDaysToAdd > 0) {
date.setDate(date.getDate() + 1);
//check if current day is business day
if (noWeekendsOrHolidays(date)[0]) {
weekDaysToAdd--;
}
}
return date;
}
function noWeekendsOrHolidays(date) {
var noWeekend = $.datepicker.noWeekends(date);
return (noWeekend[0] ? nationalDays(date) : noWeekend);
}
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}
$.datepicker.setDefaults({
beforeShowDay: noWeekendsOrHolidays,
showOn: 'both',
firstDay: 0,
dateFormat: 'dd/mm/yy',
changeFirstDay: false,
showButtonPanel: true
});
// use datepicker to choose a different delivery date
$('#datepicker3').datepicker({
minDate: AddBusinessDays(dateMin, 3)
});
})
</script>
</head>
<body>
<div>
After 3 days
<input id="datepicker3">
</div>
</body>
</html>