How to add a form to htmx
htmx can post a form to FormTango and swap in a thank-you message, with no JavaScript of your own.
- 1
Create a free FormTango account and add a form. Copy its endpoint, which looks like https://formtango.com/f/YOUR_FORM_ID.
- 2
Add the form below, replacing YOUR_FORM_ID.
- 3
Submit the form once. The submission appears in your FormTango inbox and you get an email.
html
<script src="https://unpkg.com/htmx.org@2"></script>
<form hx-post="https://formtango.com/f/YOUR_FORM_ID"
hx-headers='{"Accept": "application/json"}'
hx-swap="outerHTML"
hx-on::after-request="if (event.detail.successful) this.outerHTML = '<p>Thanks! We got your message.</p>'">
<input type="email" name="email" required>
<textarea name="message" required></textarea>
<input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send</button>
</form>Good to know
- FormTango answers with JSON, not HTML, so the thank-you text is set in hx-on rather than swapped from the response.
What you get
- Every submission saved in an inbox you can search and export.
- An email for each one, with the visitor's address as the reply-to.
- Spam filtering without making visitors solve a puzzle.
- Problems? See troubleshooting.
Related guides
Last reviewed November 19, 2026.