-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.js
More file actions
28 lines (22 loc) · 964 Bytes
/
Copy pathcontact.js
File metadata and controls
28 lines (22 loc) · 964 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
function sendMail(event) {
event.preventDefault();
let form = document.getElementById("contact-form");
let params = {
first: document.getElementById('first-name').value,
last: document.getElementById('last-name').value,
email: document.getElementById('email').value,
subject: document.getElementById('subject').value,
message: document.getElementById('message').value,
};
emailjs.send("service_4hl4slf", "template_f3em30r", params)
.then(function (response) {
console.log("SUCCESS!", response.status, response.text);
alert("Email Sent Successfully!");
form.reset();
})
.catch(function (error) {
console.error("FAILED...", error);
alert("Email failed to send. Please try again.");
});
}
document.getElementById("contact-form").addEventListener("submit", sendMail);