everyone, I'm creating a calendar with html5 that can block specific dates automatically, that information is in PHP variables, I have arrays for days, month, year to be blocked in the calendar, how can I achieve this? I just need an idea how can I do, this must be done in javascript, right?
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Calendar</title>
</head>
<body>
<?php
if(isset($_POST['reservation']) && !empty($_POST['reservation'])) {
$startDate = $_POST['start'];
$endDate = $_POST['end'];
}
?>
<form class="" action="" method="post">
<label for="start">Date init</label>
<input type="date" id="start" name="start" value="<?php echo date('Y-m-d'); ?>" min="<?php echo date('Y-m-d'); ?>" max="2021-08-10">
<label for="end">Date end</label>
<input type="date" id="end" name="end" value="<?php echo date('Y-m-d'); ?>" min="<?php echo date('Y-m-d'); ?>" max="2021-08-10">
<input type="submit" name="reservation" value="Send">
</form>
</body>
</html>
HTML input[type=date] does not support any limitation beyond setting a min and a max date [1]. Anything beyond these basics will require custom logic. If this is a reservation system, it might be an option to replicate the date selectors from eg airlines or hotels. This could be done mostly on the server with only a thin layer of JS on the client to handle the user selection.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.