forked from XceeDesigns/Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.js
30 lines (28 loc) · 1.28 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
document.addEventListener('DOMContentLoaded', function () {
const contactForm = document.getElementById('contact-form');
const contactSubmit = document.getElementById('contact-submit');
contactForm.addEventListener('submit', async function (event) {
event.preventDefault();
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();
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');
document.getElementById('contact-form').reset();
console.log(response.status);
});
});