FormturaDocs

Example contact form

A complete, styled contact page in one file. Save it as contact.html, replace YOUR_FORM_ID with your endpoint, open it in a browser, and it works. It uses fetch for a smooth result and falls back to a normal form post without JavaScript.

contact.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>Contact us</title>
  <style>
    body { font: 16px/1.5 system-ui, sans-serif; background: #f8fafc; color: #0f172a; margin: 0; padding: 2rem 1rem; }
    form { max-width: 28rem; margin: 0 auto; background: #fff; padding: 1.5rem; border: 1px solid #e2e8f0; border-radius: .75rem; }
    label { display: block; margin-bottom: 1rem; font-weight: 600; }
    input, textarea { display: block; width: 100%; box-sizing: border-box; margin-top: .25rem; padding: .5rem .75rem;
      border: 1px solid #cbd5e1; border-radius: .5rem; font: inherit; }
    button { background: #4f46e5; color: #fff; border: 0; border-radius: .5rem; padding: .6rem 1.2rem; font: inherit; cursor: pointer; }
    button[disabled] { opacity: .6; cursor: wait; }
    #status { margin-top: 1rem; }
  </style>
</head>
<body>
  <form id="contact-form" action="https://api.formtura.app/v1/submit/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" rows="4" required></textarea></label>

    <!-- Spam trap: hidden from people, filled in by bots. Keep it empty. -->
    <input type="text" name="_gotcha" tabindex="-1" autocomplete="off"
           style="position:absolute;left:-9999px" aria-hidden="true" />

    <button type="submit">Send message</button>
    <p id="status" role="status"></p>
  </form>

  <script>
    // Without JavaScript the form still works: the browser posts it and shows a thank-you page.
    const form = document.getElementById("contact-form");
    const status = document.getElementById("status");
    form.addEventListener("submit", async (event) => {
      event.preventDefault();
      const button = form.querySelector("button");
      button.disabled = true;
      status.textContent = "Sending…";
      try {
        const res = await fetch(form.action, {
          method: "POST",
          headers: { "Content-Type": "application/json", Accept: "application/json" },
          body: JSON.stringify(Object.fromEntries(new FormData(form))),
        });
        const data = await res.json().catch(() => ({}));
        if (res.ok) { form.reset(); status.textContent = data.message || "Thanks! We got your message."; }
        else { status.textContent = data.error || "Something went wrong."; }
      } catch {
        status.textContent = "Couldn't reach the server. Please try again.";
      }
      button.disabled = false;
    });
  </script>
</body>
</html>

Try it live

This is the same form talking to a real Formtura demo form. Please use sample data only. Whatever you send is stored.

Live demo · sample data only