Skip to content
Sign inJoin waitlist

Forms — Compose Digi HTML

The Compose Digi HTML template has one form, the contact form on the Contact page, and it sends to the form service or webhook of your choice.

The form checks the required fields before sending (and shows “Please enter your first name.”, “Please enter your last name.” or “Please enter a valid email address.” under the field that fails), shows a spinner while sending, says “Thank you” and clears the fields, keeps what the visitor typed when something fails (“Something went wrong”), and drops spam with a hidden honeypot field.

Out of the box it runs in demo mode: nothing is sent, and the fields are logged in the browser console. Pick a destination before you publish.

A static site has no server of its own, so submissions go to a form service or a webhook. All of these have a free tier:

Service What it does formEndpoint
Formspree Emails you each submission https://formspree.io/f/<form id>
Web3Forms Emails you each submission, no account needed https://api.web3forms.com/submit, and your key in formAccessKey
Getform, Basin Inbox, email, integrations The form’s endpoint URL
Zapier, Make, n8n, Pipedream Send submissions anywhere: Google Sheets, Slack, a CRM, a project tool The webhook (“catch hook”) URL
  1. Create a form at the service and copy its endpoint.

  2. Open assets/js/config.js and paste it:

    window.siteConfig = {
    formEndpoint: "https://formspree.io/f/abcdwxyz",
    formAccessKey: "", // Web3Forms only
    };
  3. Serve the folder (npx serve .), send a message from the Contact page and check that it arrived.

  4. Upload config.js with the site.

Every page loads the same config.js, so a form you copy onto another page sends to the same place. The sample forms in style-guide.html stay in demo mode whatever you set there (they carry data-form-demo), so they never send anything.

Each field by its name, as multipart/form-data:

Field Name Required
First Name first-name yes
Last Name last-name yes
Email email yes
Phone Number phone
Message message
Services (checkboxes) services, once for every service ticked (its name: Branding and Strategy, Email Marketing …)

The form also sends form (contact) and subject (“New contact request”), so you can tell its messages apart in your inbox or tool. With formAccessKey set, it also sends it as access_key. The honeypot field is left out. The request asks for a JSON answer (Accept: application/json), so the service answers the page instead of showing its own thank-you page. A visitor who ticks two services sends services twice: send yourself a test with two ticked to see how your service shows them.

The fields are ordinary <input> and <textarea> elements inside the <form data-form> of contact.html. Each field is a <label data-field="…"> with its label text in a <span> above the control, so the visible label is also the field’s name for screen readers:

<label data-field="phone" class="flex flex-col gap-[5px]"
><span class="text-base font-normal leading-[1.4]">Phone Number</span
><input name="phone" placeholder="+1(555) 000-0000" autocomplete="tel" type="tel" class="…"
/></label>

The first and last name sit side by side from tablets up (one column on phones); the e-mail, the phone, the message and the services take the whole width, the services in two columns from tablets up.

  • To make a field required, add required to it. The form checks it before sending and focuses the first field that fails. To show a message under it, copy the e-mail’s <span id="email-error" data-field-error hidden …> into its <label> with a new id (phone-error) and your text.
  • To make a field optional, remove required (and its <span data-field-error>).
  • To add a field, copy a <label data-field …>…</label>, give the control a new name and the label a new text. The service receives whatever the form contains, so there are no settings to update. Don’t name a field fax: it is the honeypot’s.
  • To change the services, edit the checkboxes in the <fieldset> (“Services”): each one’s value (what you receive) and the <span> after it (what the visitor reads). Copy a <label> for one more.
  • To remove a field, delete its <label>.

A field arrives under its name, so keep the names you already map somewhere. The button’s texts are written in the button: “Send message” twice (the second copy is read while the form is sending), “Thank you” and “Something went wrong”. “Thank you” and “Something went wrong” are also in the form’s data-success and data-error, which screen readers announce: change both. The title of each submission is the value of the hidden subject field: put your own wording in it.

To send visitors to a page of your own after a successful send, add data-redirect="thank-you.html" to the <form>.

  • Send a message from the live site with a real address, and reply to the test.
  • The service must answer with a success status (2xx). If it doesn’t, the visitor sees “Something went wrong” and keeps what they typed. Try it once by pasting a wrong endpoint into config.js on your local copy.
  • The browser console tells you what happened: in demo mode it logs [forms] demo mode — set formEndpoint in assets/js/config.js to send submissions with the fields; after a failure, [forms] could not send the form with the reason.

The honeypot stops the usual bots: the form carries a hidden field named fax that a person never sees; a bot that fills it is shown “Thank you” and nothing is sent. The services above filter spam on their side as well. The endpoint is visible in the page source, which is how these services are designed to work.

Submissions go only where you point them. Most countries expect you to say what happens to the data people send you (here a name, contact details and a message): choose a form service whose terms fit your obligations, and describe it in a privacy policy. The template has no privacy page; add one (Editing the site) and link it from the footer. The form has no consent checkbox: add one as a required checkbox if your visitors need it.