-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
27 lines (24 loc) · 970 Bytes
/
script.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
// Contact Form Validation
document.querySelector("form").addEventListener("submit", function(event) {
event.preventDefault();
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let message = document.getElementById("message").value;
if (name === "" || email === "" || message === "") {
alert("Please fill in all fields.");
} else {
alert("Thank you for contacting me!");
document.getElementById("name").value = "";
document.getElementById("email").value = "";
document.getElementById("message").value = "";
}
});
// Navbar Smooth Scrolling
document.querySelectorAll('.navbar-nav a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});