-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.js
96 lines (76 loc) · 4.19 KB
/
insert.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
let submenu = document.getElementById("submenu")
function toggleMenu(){
submenu.classList.toggle("open-menu");
}
const logoutLink = document.querySelector(".sub-menu-link");
logoutLink.addEventListener("click", function() {
// Redirect to the Login.html page
window.location.href = "Login.html";
});
const createEventsLink = document.querySelector('.nav_link_events');
const createEventsSubMenuLink = document.querySelector('.sub_menu_1 a');
const createUpdatesSubMenuLink = document.querySelector('.submenu-update');
const createRemoveSubMenuLink = document.querySelector('.submenu-delete');
const eventContainer = document.querySelector('.event-container');
const updateContainer = document.querySelector('.update-container');
const deleteContainer = document.querySelector('.delete-container');
const formCloseButton = document.querySelector('.form_close');
const formCloseButton2 = document.querySelector('.form_close2');
const formCloseButton3 = document.querySelector('.form_close3');
const homeElement = document.querySelector('.home');
// Function to open the event container
function openEventContainer() {
eventContainer.style.display = 'block';
homeElement.classList.add('show');
}
// Function to close the event container
function closeEventContainer() {
eventContainer.style.display = 'none';
homeElement.classList.remove('show');
}
function openUpdateContainer() {
updateContainer.style.display = 'block';
homeElement.classList.add('show');
}
// Function to close the event container
function closeUpdateContainer() {
updateContainer.style.display = 'none';
homeElement.classList.remove('show');
}
function openDeleteContainer() {
deleteContainer.style.display = 'block';
homeElement.classList.add('show');
}
// Function to close the event container
function closeDeleteContainer() {
deleteContainer.style.display = 'none';
homeElement.classList.remove('show');
}
// Event listener for clicking the "Create Events" link in the main menu
createEventsLink.addEventListener('click', openEventContainer);
// Event listener for clicking the "Create Events" link in the sub-menu
createEventsSubMenuLink.addEventListener('click', openEventContainer);
// Event listener for clicking the form close button
formCloseButton.addEventListener('click', closeEventContainer);
// Event listener for clicking the "update Events" link in the main menu
createEventsLink.addEventListener('click', openUpdateContainer);
// Event listener for clicking the "update Events" link in the sub-menu
createUpdatesSubMenuLink.addEventListener('click', openUpdateContainer);
// Event listener for clicking the form close button
formCloseButton2.addEventListener('click', closeUpdateContainer);
// Event listener for clicking the "delete Events" link in the main menu
createEventsLink.addEventListener('click', openDeleteContainer);
// Event listener for clicking the "delete Events" link in the sub-menu
createRemoveSubMenuLink.addEventListener('click', openDeleteContainer);
// Event listener for clicking the form close button
formCloseButton3.addEventListener('click', closeDeleteContainer);
function validateForm() {
var eventDate = document.getElementById('event_date').value;
var today = new Date().toISOString().split('T')[0]; // Get the current date in YYYY-MM-DD format
if (eventDate < today) {
alert("Please select a future date.");
return false; // Prevent the form submission
}
// If the date is valid, allow the form to be submitted
return true;
}