HTML and JavaScript
Start with a native form
Use the quickstart form first. Native submission requires no client script and takes the visitor to a confirmation page when the endpoint accepts their input.
Add Fetch for inline feedback
Keep the action and method in the markup. Add a submit listener to post the current fields, prevent duplicate clicks while sending, and show the resulting state in a visible status element.
<form id="contact-form" method="post" action="https://api.bitebrake.com/api/submit">
<input type="hidden" name="access_key" value="YOUR_FORM_KEY">
<label for="contact-email">Email</label>
<input id="contact-email" type="email" name="email" autocomplete="email" required>
<label for="contact-message">Message</label>
<textarea id="contact-message" name="message" rows="5" required></textarea>
<input name="botcheck" type="text" hidden tabindex="-1" autocomplete="off">
<button type="submit">Send message</button>
</form>
<p id="form-status" role="status"></p>
<script type="module">
const form = document.querySelector('#contact-form');
const status = document.querySelector('#form-status');
const submitButton = form.querySelector('button[type="submit"]');
form.addEventListener('submit', async (event) => {
event.preventDefault();
submitButton.disabled = true;
status.textContent = 'Sending…';
try {
const response = await fetch(form.action, {
method: 'POST',
headers: { Accept: 'application/json' },
body: new FormData(form),
});
const result = await response.json();
status.textContent = result.error ?? result.message;
if (response.ok && result.success) form.reset();
} catch {
status.textContent = 'A connection error occurred. Check your connection and try again.';
} finally {
submitButton.disabled = false;
}
});
</script>
Verify browser policy
If your page sets a Content Security Policy, add the Forms4Web origin to form-action for native submission, and to connect-src for Fetch. Test the deployed page on a keyboard and a narrow screen.