HTML Contact Form with only Frontend Code
Start collecting form submissions from your HTML form with FormAPI in 2 minutes. Create your form in FormAPI and paste your unique URL inside your form. Check out the code examples and detailed tutorial below to get started.
VS Code
<form id="contactForm">
<label>Email:</label>
<input type="email" name="email" required />
<label>Message:</label>
<textarea name="message" required></textarea>
<button type="submit">Send</button>
</form>
<script>
const form = document.getElementById('contactForm');
form.addEventListener('submit', async function (e) {
e.preventDefault();
const formData = new FormData(form);
try {
const res = await fetch('https://submit.zunoy.com/sub/[YOUR-FORM-KEY]', {
method: 'POST',
body: formData
});
alert('Form submitted successfully!');
} catch (error) {
alert('Error: ' + error.message);
}
});
</script>How to Integrate Code
What is HTML?
HTML (HyperText Markup Language) is the standard language for creating web pages. With FormAPI, you can easily collect form submissions from your HTML forms without needing a backend.
FormAPI Setup with HTML using Fetch
Fetch is a built-in JavaScript API that allows you to send form data easily. Below is an example demonstrating how to send form submissions from an HTML form to FormAPI using Fetch. Ensure that you replace “https://submit.zunoy.com/sub/[YOUR-FORM-KEY]” with your unique mockapi URL.
VS Code
<script>
function submitForm(event) {
event.preventDefault();
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
fetch('https://submit.zunoy.com/sub/[YOUR-FORM-KEY]', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, message })
})
.then(response => response.json())
.then(data => {
if (data.code === 200) {
alert('Form submitted successfully!');
} else {
alert('Error: ' + data.message);
}
})
.catch(error => console.error('Error:', error));
}
</script>
<form onsubmit="submitForm(event)">
<input type="email" id="email" placeholder="Email" required />
<textarea id="message" placeholder="Message" required></textarea>
<button type="submit">Submit</button>
</form>FormAPI Setup with HTML using Axios
Axios is a promise-based HTTP client that simplifies API requests. Below is an example showing how to send form submissions from an HTML form to FormAPI using Axios. Ensure that you replace “https://submit.zunoy.com/sub/[YOUR-FORM-KEY]” with your unique mockapi URL.
VS Code
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
function submitForm(event) {
event.preventDefault();
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
axios.post('https://submit.zunoy.com/sub/[YOUR-FORM-KEY]', { email, message })
.then(response => {
if (response.data.code === 200) {
alert('Form submitted successfully!');
} else {
alert('Error: ' + response.data.message);
}
})
.catch(error => console.error('Error:', error));
}
</script>
<form onsubmit="submitForm(event)">
<input type="email" id="email" placeholder="Email" required />
<textarea id="message" placeholder="Message" required></textarea>
<button type="submit">Submit</button>
</form>FormAPI Setup for File Uploads in HTML
To upload files in an HTML form using FormAPI, you can use FormData along with Axios or Fetch. The example below demonstrates how to handle file uploads in an HTML form. Ensure that you replace “https://submit.zunoy.com/sub/[YOUR-FORM-KEY]” with your own unique mockapi URL.
VS Code
<script>
function uploadFile(event) {
const file = event.target.files[0];
if (!file) return;
const formData = new FormData();
formData.append('file', file);
fetch('https://submit.zunoy.com/sub/[YOUR-FORM-KEY]', {
method: 'POST',
body: formData
})
.then(response => response.ok ? alert('File uploaded successfully!') : alert('Upload failed.'))
.catch(error => console.error('Error:', error));
}
</script>
<input type="file" onchange="uploadFile(event)" />Set Up FormAPI in 60 Seconds
Create Your Form
Sign up and create a form in FormAPI — no backend code required.
Get Your Endpoint
FormAPI gives you a unique endpoint. Point your form's action attribute (or a fetch/axios call) at it.
Start Receiving Submissions
Submissions land instantly in your dashboard inbox, with spam filtering and alerts built in.
USE CASES
Need templates? Say less.
A collection of example HTML forms with code that you can edit live, then download or copy/paste. A minimal form reset css is included that should work with most sites.
Simple Contact Form
Survey Form
Book a Demo Form
News Letter Form
Registration Form & more...
Ready to Experience Zunoy?
Start your journey with Zunoy's powerful suite of tools, designed for startups, developers, and growing teams alike.
FormAPI
Collect submissions without a backend—add a headless mockapi to any <form>
Operational
Contact Us On
Mail Us
support@zunoy.comCopyright © 2026 - Mentcube Innovations Pvt Ltd.. All Rights Reserved.