forked from XceeDesigns/Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.js
37 lines (33 loc) · 1.42 KB
/
contact.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
31
32
33
34
35
36
37
// for handling form submission
document.addEventListener('DOMContentLoaded', function () {
const contactForm = document.getElementById('contact-form');
const contactSubmit = document.getElementById('contact-submit');
contactForm.addEventListener('submit', async function (event) {
event.preventDefault();
// sending data back to API
const response = await fetch('https://xceedesigns-backend.vercel.app/contact', {
method: 'POST',
body: JSON.stringify({
name: document.getElementById('name').value,
email: document.getElementById('email').value,
message: document.getElementById('message').value
}),
headers: {
'Content-Type': 'application/json'
}
});
const parsedResponse = await response.text();
// modal info
const modalBody = document.querySelector('.modal-body');
const modalTitle = document.querySelector('.modal-title');
modalTitle.textContent = 'XceeDesigns LLC.';
modalTitle.style.fontWeight = 'bold';
modalBody.textContent = "Thank you for contacting us. We'll get back to you soon!";
// modalBody.style.color = '#04aa6d';
$('#myModal').modal('show');
//reset form
document.getElementById('contact-form').reset();
//log status
console.log(response.status);
});
});