javascript init

This commit is contained in:
Muyao CHEN 2024-06-29 15:21:09 +02:00
parent d7f978a884
commit 52d4d40140

View File

@ -60,7 +60,7 @@
<div class="col-md-6"> <div class="col-md-6">
<h1 class="text-center mt-3">Search for Availability</h1> <h1 class="text-center mt-3">Search for Availability</h1>
<form action="reservation.html" method="get"> <form action="reservation.html" method="get" novalidate class="needs-validation">
<div class="row"> <div class="row">
<div class="col mb-3"> <div class="col mb-3">
<label for="start_date" class="form-label">Starting Date</label> <label for="start_date" class="form-label">Starting Date</label>
@ -103,6 +103,27 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script> crossorigin="anonymous"></script>
<script>
(() => {
'use strict'
// Fetch all the forms we want to apply custom Bootstrap validation styles to
const forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.from(forms).forEach(form => {
form.addEventListener('submit', event => {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>
</body> </body>
</html> </html>