All guides

Alpine.js

Keep Alpine’s live message counter while sending the form through the browser.

Copy your endpoint

Open your form in Wiztrom and copy its endpoint from Setup. Replace the example URL with that address. If you created your form from a template, use the field names and required fields from its Setup HTML.

Add a counter to your Alpine page

Place this markup in a page that already loads Alpine. The x-data scope tracks the textarea through x-model. Keep the name attribute so the browser includes the message in the POST.

HTML
<form x-data="{ message: '' }" action="https://forms.wiztrom.com/f/YOUR_FORM_ID" method="post">
  <label>Name <input name="name" required /></label>
  <label>Email <input name="email" type="email" required /></label>
  <label>Message <textarea x-model="message" name="message" required></textarea></label>
  <p x-text="message.length + ' characters'"></p>
  <button type="submit">Send message</button>
</form>

Check the counter and the submit

Type a short message and watch the count change. Remove @submit.prevent from a migrated form when using this native action. The form still submits when Alpine is disabled.

Find the test in your inbox

On the published page, leave a required field empty and try Send. Fill it in, enter a distinctive test message and submit once. Open the form’s Wiztrom inbox and match the submitted values. If you enabled a notification, open delivery history and check its result.

References