-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyscripts.js
32 lines (24 loc) · 949 Bytes
/
myscripts.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
document.querySelectorAll('nav ul li a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
targetSection.scrollIntoView({
behavior: 'smooth'
});
}
});
});
document.querySelector('form').addEventListener('submit', function (e) {
e.preventDefault();
const name = this.querySelector('input[name="Name"]').value;
const email = this.querySelector('input[name="Email"]').value;
const message = this.querySelector('textarea').value;
if (name === "" || email === "" || message === "") {
alert("Please fill in all fields.");
} else {
alert("Form submitted successfully!");
this.reset();
}
});