jQuery
jQuery still powers plenty of production sites, and wiring one of its forms to Formstork takes only a few lines. You can drop in the @formstork/js SDK or write a small jQuery submit handler that posts to the API yourself.
Using the @formstork/js SDK
npm install @formstork/js
import { formstork } from "@formstork/js";
const form = document.querySelector("#contact");
formstork(form, {
accessKey: "YOUR_ACCESS_KEY",
onSuccess: () => alert("Thanks, your message was sent."),
onError: (message) => alert(message),
});
formstork(form, options) attaches a submit handler, collects the fields, and posts them for you, so you never touch the network call.
Plain jQuery submit handler
Prefer to stay dependency free? Add a hidden access_key field and post the form yourself:
<form id="contact">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
<input type="email" name="email" required />
<textarea name="message" required></textarea>
<button type="submit">Send</button>
</form>
$("#contact").on("submit", async function (e) {
e.preventDefault();
const res = await fetch("https://api.formstork.com/submit", {
method: "POST",
body: new FormData(this),
headers: { Accept: "application/json" },
});
const data = await res.json();
alert(data.message);
if (data.success) this.reset();
});
The Accept: application/json header tells Formstork to reply with JSON, so you can read data.success and show data.message to your visitor.
Step by step
- Sign up at app.formstork.com and copy your free access key from the dashboard.
- Add a form with a hidden
access_keyinput set toYOUR_ACCESS_KEY. - Load jQuery, then either install
@formstork/jsor paste the submit handler above. - Bind the handler to the form’s submit event and call
preventDefaultto stop the page reload. - Post the
FormDatatohttps://api.formstork.com/submitwith theAccept: application/jsonheader. - Read
data.successand showdata.messageto the visitor. - Send a test message and confirm it lands in your dashboard.
The free plan covers 250 submissions a month, which is plenty to launch a contact form.