Verified Commit 24db3fd3 authored by Nicolai Van der Storm's avatar Nicolai Van der Storm
Browse files

added contact form

parent be4e6f85
Pipeline #601211859 passed with stages
in 2 minutes and 25 seconds
......@@ -45,6 +45,7 @@ topText = [
"Made with &#10084; by <a href=\"https://nvds.be\">Nicolai Van der Storm</a>",
]
bottomText = [
"<a href=\"/contact\">Contact</a>",
"<a href=\"/privacy\">Privacy Policy</a>",
"Powered by <a href=\"http://gohugo.io\">Hugo</a>",
]
......
---
title: ""
date: 2022-07-28T17:15:02+02:00
draft: false
---
<section class="get-in-touch">
<h1 class="title">Get in touch</h1>
<form action="#" method="post" class="contact-form row">
<div class="form-field col x-50">
<input name="Name" id="name" class="input-text js-input" type="text" placeholder="" required>
<label class="label" for="name">Name</label>
</div>
<div class="form-field col x-50">
<input name="Email" id="email" class="input-text js-input" type="email" placeholder="" required>
<label class="label" for="email">E-mail</label>
</div>
<div class="form-field col x-100">
<input name="Message" id="message" class="input-text js-input" type="text" placeholder="" required>
<label class="label" for="message">Message</label>
</div>
<div class="form-field col x-100 align-center">
<input class="submit-btn" type="submit" value="Submit">
</div>
</form>
</section>
<script !src="">
// 6eZQtIgL05fk1GDUklmd6CNDRndEm3cajw89YYhf
const form = document.querySelector('.contact-form');
const button = document.querySelector('.submit-btn');
form.addEventListener('submit', (e) => {
//disable the button
button.setAttribute('disabled', 'disabled');
button.value = 'Sending...';
e.preventDefault();
const values = new FormData(e.target)
const payload = Object.fromEntries(values.entries());
fetch('https://api.nvds.be/api/v1/db/data/v1/Contact_From/Contact_Table', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'xc-token': '6eZQtIgL05fk1GDUklmd6CNDRndEm3cajw89YYhf'
},
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
//set button text to message sent and color to green
button.value = 'Message sent';
// set button cursor to block
button.style.cursor = 'not-allowed';
})
})
</script>
Subproject commit 2045cc8a57e4e15c62a6cd1351ec6aa13e1cbc3e
Subproject commit 7a8879612e5d523502f477263569ed6a4a2b4877
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment