-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (44 loc) · 1.62 KB
/
script.js
File metadata and controls
53 lines (44 loc) · 1.62 KB
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
document.addEventListener('DOMContentLoaded', () => {
// Form validation
const form = document.querySelector('.form');
const emailInput = form.querySelector('input[type="email"]');
const passwordInput = form.querySelector('input[type="password"]');
const loginButton = form.querySelector('.btnn');
loginButton.addEventListener('click', (e) => {
e.preventDefault();
validateForm();
});
function validateForm() {
const email = emailInput.value;
const password = passwordInput.value;
if (!validateEmail(email)) {
alert('Please enter a valid email address.');
return false;
}
if (password.length < 6) {
alert('Password must be at least 6 characters long.');
return false;
}
alert('Form submitted successfully!');
return true;
}
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(String(email).toLowerCase());
}
// Interactive menu
const menuItems = document.querySelectorAll('.menu ul li a');
menuItems.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
alert(`You clicked on ${item.textContent}`);
});
});
// Dynamic content update
const joinUsButton = document.querySelector('.cn a');
const contentSection = document.querySelector('.content .par');
joinUsButton.addEventListener('click', (e) => {
e.preventDefault();
contentSection.innerHTML = 'Thank you for joining us! Stay tuned for updates.';
});
});