-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (33 loc) · 1004 Bytes
/
script.js
File metadata and controls
42 lines (33 loc) · 1004 Bytes
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
function scrollGallery(direction) {
const galleryContainer = document.getElementById('galleryContainer');
const scrollAmount = 320;
galleryContainer.scrollLeft += direction * scrollAmount;
}
// can add auto-scroll in every 3 seconds
setInterval(() => {
scrollGallery(1);
}, 3000);
const contactForm = document.getElementById('contactForm');
contactMe(contactForm);
function contactMe(form) {
form.addEventListener('submit', (event) => {
event.preventDefault(); // prevennt from default submitting
const name = form.name.value.trim();
const email = form.email.value.trim();
const message = form.message.value.trim();
if(!name || !email || !message) {
alert('All fields are required');
return;
}
console.log("Form submitted", {
name,
email,
message
});
alert(`Thank you for your message, ${name}`);
// reset form
form.reset();
// to submit to actual form, can make use of form.submit()
return ;
})
}