JavaScript dynamic form
Build a dynamic, schema-driven form with plain JavaScript and no backend. Render the inputs from a fields array with createElement, so you add or reorder fields by editing data. It posts once to Formpaste. Copy the code and add your access key.
How to build it
- Create a form in your Formpaste dashboard and copy its access key.
- Copy the code below and edit the fields array to your form.
- Replace YOUR_ACCESS_KEY_HERE with your access key, then publish.
Prompt for your AI coding agent
Add a Formpaste dynamic form to my page with vanilla JavaScript. Build the inputs from a fields array using document.createElement so adding or reordering a field means editing data, not markup, and add a submit listener that POSTs new URLSearchParams(new FormData(form)) once to https://api.formpaste.com/submit with a hidden access_key. No framework and no backend.Or connect the Formpaste MCP server to Claude Code, Codex, Cursor, Claude Desktop, VS Code, or any mcp-remote client. See the setup guide.
JavaScript gotchas
A vanilla JavaScript contact form is plain HTML plus a submit listener. Point the form at Formpaste, add a script that calls preventDefault and posts the FormData with fetch, and the visitor stays on the page. No framework, no build step, no backend.
It is a form plus a listener
Keep the real form markup with an action pointing at the Formpaste endpoint, then add a submit listener that calls preventDefault and posts with fetch. There is no framework and nothing to install, so the same snippet works in a static site, a CMS template, or a hand-written page.
Progressive enhancement is free
Because the markup is a real form with an action, it still submits if your script fails to load or JavaScript is switched off. The listener is an upgrade that keeps the visitor on the page, not a requirement.
Post FormData, not a hand-built object
Build the body with new FormData(form) so every field comes along by name, including the hidden access_key. Wrap it in URLSearchParams for a normal text form, or post the FormData directly when the form has a file input.
Handle the response yourself
The endpoint returns JSON (success, message, id). Await the fetch and show your own success or error message, then call form.reset(). Or set a redirect URL in the dashboard and let the plain form post do the work with no script at all.
What to get right
The fields come from a schema, not the markup
A dynamic form renders its inputs from an array of field definitions, so you add or reorder fields by editing data, not JSX or template markup. The same component handles any field-set.
One submit for any shape
However many fields the schema has, the form posts once to Formpaste as a single submission. Keep the hidden access_key input in the payload and the field names meaningful so your inbox is readable.
Keep field names stable
The field name is what shows up in your inbox and exports, so name each schema entry clearly (name, email, message) even as you change labels or order. Formpaste stores whatever names you send.
How it works
Three simple steps for form submissions to land in your email inbox.
Create your form, set your form's action URL to Formpaste's endpoint, and add your access key.
Create your form
Sign up, verify your email, and create an access key in your dashboard.
Copy the code
Paste the snippet above into your project. Pick CSS or Tailwind to match your site.
<form id="form" action="https://api.formpaste.com/submit" method="POST">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY_HERE">
<button type="submit">Send</button>
</form>
<script>
const fields = [
{ name: "name", type: "text", label: "Name" },
{ name: "email", type: "email", label: "Email" },
{ name: "message", type: "textarea", label: "Message" },
];
const form = document.getElementById("form");
const submit = form.querySelector("button");
for (const f of fields) {
const label = document.createElement("label");
label.textContent = f.label + " ";
const input = document.createElement(f.type === "textarea" ? "textarea" : "input");
if (f.type !== "textarea") input.type = f.type;
input.name = f.name;
label.appendChild(input);
form.insertBefore(label, submit);
}
form.addEventListener("submit", async (e) => {
e.preventDefault();
await fetch(form.action, { method: "POST", body: new URLSearchParams(new FormData(form)) });
form.reset();
});
</script>
Add your access key
Replace the placeholder with your access key to start receiving submissions.
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY_HERE">JavaScript dynamic form FAQ
Paste a form. Get submissions.
Instantly without setting up any backend, servers or databases. 250 submissions/mo free - no credit card.