-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreservation.js
29 lines (24 loc) · 981 Bytes
/
reservation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function submitForm() {
var nameInput = document.getElementById('name').value;
var phoneInput = document.getElementById('phone').value;
var dateInput = document.getElementById('date').value;
var timeInput = document.getElementById('time').value;
var numberOfPeopleInput = document.getElementById('numberOfPeople').value;
var errorMessage = document.getElementById('errorMessage');
errorMessage.innerText = "";
if (!nameInput || !phoneInput || !dateInput || !timeInput || !numberOfPeopleInput) {
errorMessage.innerText = "Please fill out all fields";
return;
}
if (phoneInput.length !== 10 || isNaN(phoneInput)) {
errorMessage.innerText = "Phone number must be a 10-digit number";
return;
}
var currentTime = new Date();
var selectedTime = new Date(dateInput + " " + timeInput);
if (selectedTime < currentTime) {
errorMessage.innerText = "Booking Unavailable";
return;
}
errorMessage.innerText = "Table Reserved";
}