Docs / Frameworks
Contact form in plain HTML
A plain HTML form that emails you every submission. Works on any host and any static site generator.
<form action="https://wrenform.com/f/YOUR_FORM_ID" method="POST">
<input type="text" name="name" required>
<input type="email" name="email" required>
<textarea name="message" required></textarea>
<input type="text" name="_honey" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send</button>
</form>
<!-- Optional: a timing check against bots, and data-ajax to submit in place -->
<script src="https://wrenform.com/js/v1/form.js" defer></script>Steps
- Create a form and copy its form ID from the Setup page.
- Paste the snippet into your page and replace
YOUR_FORM_ID. - Add labels and styles as you like. Keep
method="POST", everynameattribute and the hidden_honeyfield. - Deploy, then add your site's origin (for example
https://example.com) under Allowed origins in the form's settings.
Any static site generator works the same way: put the form in a template or a partial. Eleventy, Jekyll and plain hosting need nothing else.
Test it
Open the page on your site, fill in the form and send it. You should land on our thank-you page, see the submission in your dashboard, and get an email. To send visitors to your own page instead, see redirects.
Strict Content-Security-Policy sites
If your site sends a strict Content-Security-Policy header, use this version. It needs no JavaScript, no inline styles and no CAPTCHA script.
<form action="https://wrenform.com/f/YOUR_FORM_ID" method="POST">
<label>Name <input type="text" name="name" required></label>
<label>Email <input type="email" name="email" required></label>
<label>Message <textarea name="message" required></textarea></label>
<!-- Where to go after sending (must be on one of the form's allowed origins) -->
<input type="hidden" name="_redirect" value="https://example.com/thanks/">
<!-- Spam trap: hidden with the hidden attribute, so no inline style is needed -->
<input type="text" name="_honey" hidden tabindex="-1" autocomplete="off">
<button type="submit">Send</button>
</form>Add Wrenform to your policy's form-action directive:
Content-Security-Policy: default-src 'self'; form-action 'self' https://wrenform.comhttps://wrenform.comlets the browser post the form to us.'self'lets the browser follow our redirect back to your own thank-you page. Some browsers checkform-actionagainst redirects after a form post, too.- Nothing else changes. This version needs no
script-src,style-srcorconnect-srcentry.
Your own thank-you page. Pick one:
- Set Redirect to in the form's settings (for example
https://example.com/thanks/). This needs nothing in the HTML. - Or keep the
_redirectfield as above. We follow it only when its origin is in the form's allowed origins (or, with none set, when it matches the page that posted). Otherwise we ignore it and use Redirect to, then our own thank-you page.
Timing field. The honeypot catches most bots. The timing check catches bots that post within 3 seconds of loading the page. With no JavaScript, you can use it only if the page is rendered per request: write the render time, in Unix milliseconds, into a hidden field.
<input type="hidden" name="_t" value="1765880100000">On a static site, the value would be the build time, which we ignore after 24 hours. Instead, serve a small script from your own domain. script-src 'self' already allows it, so the policy doesn't change.
// Load with <script src="/js/form-timing.js" defer></script>
// Fills _te with the milliseconds since the page loaded.
for (const form of document.querySelectorAll('form[action^="https://wrenform.com/f/"]')) {
const field = Object.assign(document.createElement("input"), { type: "hidden", name: "_te" });
form.append(field);
form.addEventListener("submit", () => {
field.value = String(Math.round(performance.now()));
});
}Don't add a CAPTCHA. Spam filtering runs on our side by default. If you add Cloudflare Turnstile later, its script and frame need their own CSP entries; see spam.
Live example
Coming at launch: a working form on this page, under this exact policy, that posts to Wrenform and comes back to a thank-you page here.
Common problems
origin_not_allowedon a local file. Pages opened from disk (file://) are always rejected. Test from a local web server or your live site.- The form posts but the browser stays put. Your CSP's
form-actionblocks the post or the redirect. Check the browser console and add the entries above. - The honeypot shows up. Your CSP blocks inline
styleattributes. Use thehiddenattribute, as in the strict version. - Fields are missing in the email. The input has no
name, or it's disabled. Disabled inputs aren't sent.
Next steps
- My form isn't working: symptom, cause and fix.
- Redirects: your own thank-you page, or stay on the page with JavaScript.
- Spam: how the filters work, and Turnstile.
- Fields: reserved fields, lists and checkboxes, limits.