Forms — Marai Neesu HTML
The Marai Neesu HTML template has two forms, and they send to the form service or webhook of your choice: a project inquiry and a newsletter sign-up.
The inquiry is on the Contact page and the sign-up in the newsletter box of the Blog. Each form checks the required fields, 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 they run in demo mode: nothing is sent, and the fields are logged in the browser console. Pick a destination before you publish.
Connect a form service
Section titled “Connect a form service”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, your newsletter tool | The webhook (“catch hook”) URL |
-
Create a form at the service and copy its endpoint.
-
Open
assets/js/config.jsand paste it:window.siteConfig = {formEndpoint: "https://formspree.io/f/abcdwxyz",formAccessKey: "", // Web3Forms only}; -
Serve the folder (
npx serve .), submit each form (one inquiry from the Contact page, one sign-up from the Blog) and check that the submissions arrived. -
Upload
config.jswith the site.
Every page loads the same config.js, so one endpoint serves both forms. 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.
Newsletter subscribers
Section titled “Newsletter subscribers”The sign-up sends an e-mail address; it doesn’t add anyone to a mailing list by itself. To collect subscribers in
Mailchimp, Brevo, ConvertKit or another newsletter tool, point formEndpoint at an automation (Zapier, Make, n8n): let it
add the address to your list when form is newsletter, and e-mail you the inquiry when form is contact. With a
service that only e-mails you (Formspree, Web3Forms), you receive each new address and add it yourself.
Newsletter tools usually send a confirmation e-mail first (double opt-in): keep that on, it’s what most countries expect.
What the service receives
Section titled “What the service receives”Each field by its name, as multipart/form-data.
The inquiry on the Contact page (button “Send message”):
| Field | Name | Required |
|---|---|---|
| First Name | firstName |
yes |
| Last Name | lastName |
yes |
email |
yes | |
| Phone Number | phone |
yes |
| I’m interested in …: Product Design, Web Design, Mobile App Design, User Experience (UX) Design (tick boxes) | interests |
|
| Project Budget (USD) | budget |
yes |
| Message | message |
A visitor can tick several boxes: each ticked box is sent as its own interests value, so the service receives
interests once per choice (most list them together).
The newsletter sign-up on the Blog (button “Subscribe”): email (required).
Each form also sends form and subject, so you can tell them apart in your inbox or tool:
| Form | form |
subject |
|---|---|---|
| Inquiry | contact |
New contact inquiry |
| Newsletter | newsletter |
New newsletter subscriber |
With formAccessKey set, the forms also send 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.
Changing the fields
Section titled “Changing the fields”The fields are ordinary <input> and <textarea> elements inside the <form data-form> of contact.html and
blog.html, each in a <label> with its text (the newsletter’s single field is named by its aria-label). Change a
label or a placeholder in place. The interests are the <label>s inside the <fieldset> “I’m interested in …”: each
holds a tick box <input type="checkbox" name="interests" value="…"> and its text. They are typed in contact.html,
not read from your services, so make them match your own (copy a <label> to add one, and change its value and its
text).
- To make a field required, add
requiredto it; the browser checks it before sending. The form shows no mark on required fields, as in the original design: say so in the label if you like (“Phone Number (optional)” for the others). - To make a field optional, remove
required(the phone number and the budget are required in the demo). - To add a field, copy a
<label>…</label>and give its input a newname. The service receives whatever the form contains, so there are no settings to update. Don’t name a fieldfax: it is the honeypot’s. - To remove a field, delete its
<label>…</label>(or, for First Name and Last Name, which share a row, the<label>and, if you like, the row around the other one).
A field arrives under its name, so keep the names you already map somewhere. The button’s texts are written in the
button: the label twice (the second copy is read by screen readers 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.
To send visitors to a page of your own after a successful send, add data-redirect="thank-you.html" to the <form>.
Testing before launch
Section titled “Testing before launch”- Submit both forms on the live site with a real address, and reply to the test inquiry.
- 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.json 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 submissionswith the fields; after a failure,[forms] could not send the formwith the reason.
Spam and privacy
Section titled “Spam and privacy”The honeypot stops the usual bots: every 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: the inquiry collects a name, an e-mail address, a phone number and a budget, and the sign-up an e-mail address for your newsletter. Marai Neesu has no consent checkbox and no privacy page: add a page with your privacy notice (Editing the site) and link it under the forms or in the footer.