Skip to content

Commit d10028d

Browse files
authored
Create contact.js
1 parent a6e8004 commit d10028d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

js/contact.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function handleSubmit(event) {
2+
event.preventDefault();
3+
4+
// Get form values
5+
const formData = {
6+
name: event.target[0].value,
7+
email: event.target[1].value,
8+
message: event.target[2].value
9+
};
10+
11+
// Basic validation
12+
if (!formData.name || !formData.email || !formData.message) {
13+
alert('Please fill in all fields');
14+
return;
15+
}
16+
17+
// Simulate form submission
18+
console.log('Form submitted:', formData);
19+
20+
// Show success message
21+
alert('Message sent successfully! We\'ll respond within 24 hours.');
22+
23+
// Reset form
24+
event.target.reset();
25+
}
26+
27+
// Add input validation styling
28+
document.querySelectorAll('input, textarea').forEach(element => {
29+
element.addEventListener('invalid', (e) => {
30+
e.target.style.borderColor = '#ff4757';
31+
});
32+
33+
element.addEventListener('input', (e) => {
34+
e.target.style.borderColor = '#2a2f45';
35+
});
36+
});

0 commit comments

Comments
 (0)