-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (28 loc) · 1.22 KB
/
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
28
29
30
document.getElementById('emailForm').addEventListener('submit', function (e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
emailjs.send('[email protected]', 'your_template_id', {
from_name: name,
from_email: email,
message: message
})
.then((response) => {
console.log('SUCCESS!', response.status, response.text);
document.getElementById('status').innerText = 'Email sent successfully!';
document.getElementById('status').style.color = 'green';
document.getElementById('status').style.opacity = 1;
setTimeout(() => {
document.getElementById('status').style.opacity = 0;
}, 3000);
}, (error) => {
console.error('FAILED...', error);
document.getElementById('status').innerText = 'Error sending email. Please try again.';
document.getElementById('status').style.color = 'red';
document.getElementById('status').style.opacity = 1;
setTimeout(() => {
document.getElementById('status').style.opacity = 0;
}, 3000);
});
});