# Alpine.js form to email

> Send an Alpine.js form to email with FormDoc. A few lines of x-data and fetch show a success message, with no build step or server.

With Alpine.js you can send a form to FormDoc and show the result in place, straight from your HTML.

HTML

```html
<form
  action="https://api.formdoc.dev/v1/submit"
  method="POST"
  x-data="{ status: '' }"
  @submit.prevent="
    status = 'Sending…';
    fetch($el.action, { method: 'POST', headers: { Accept: 'application/json' }, body: new FormData($el) })
      .then((res) => res.json())
      .then((result) => {
        status = result.success ? 'Thanks, message sent.' : result.error.message;
        if (result.success) $el.reset();
      })
      .catch(() => { status = 'Your message couldn’t be sent. Please try again.'; });
  "
>
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">
  <input type="text" name="name" required>
  <input type="email" name="email" required>
  <textarea name="message" required></textarea>
  <input type="checkbox" name="botcheck" style="display:none" tabindex="-1" autocomplete="off">
  <button type="submit">Send</button>
  <p role="status" x-text="status"></p>
</form>
```

Replace `YOUR_ACCESS_KEY` with your key from [app.formdoc.dev/new](https://app.formdoc.dev/new). The form keeps its `action`, so it still sends if Alpine doesn’t load.
