Basic form structure and submission
What we will go through
- A complete contact form example
- Sending submissions without a server
- Thank you pages and error messages
- Simple spam protection
Short answer
A good contact form has a short list of linked labels and fields, sensible input types, required fields marked in text, and one clear submit button. On a static site, point the action at a form service. Send visitors to a thank you page after they submit, and add a hidden honeypot field to stop simple spam bots.
A complete contact form
<form action="https://formspree.io/f/your-id" method="post">
<p>
<label for="name">Full name (required)</label>
<input type="text" id="name" name="name" autocomplete="name" required>
</p>
<p>
<label for="email">Email (required)</label>
<input type="email" id="email" name="email" autocomplete="email" required>
</p>
<p>
<label for="mobile">Mobile number</label>
<input type="tel" id="mobile" name="mobile" autocomplete="tel">
</p>
<p>
<label for="message">Message (required)</label>
<textarea id="message" name="message" rows="5" required></textarea>
</p>
<p hidden>
<label for="website">Leave this empty</label>
<input type="text" id="website" name="_gotcha" tabindex="-1" autocomplete="off">
</p>
<button type="submit">Send message</button>
</form>
Sending without your own server
Static sites on GitHub Pages or Netlify have no server code. Form services receive submissions and forward them to your email. You sign up, get a unique URL, and put it in action. Read their free plan limits, usually a set number of submissions per month.
Thank you pages and errors
After submitting, send people to a page that confirms the message was received and says what happens next, like We reply within one business day. Most form services let you set a redirect URL. If validation fails, the error should say exactly what to fix, next to the field.
Stopping spam
A honeypot is a hidden field that humans never see. Bots fill every field, so if it has a value, the service drops the submission. It stops most simple bots without making real visitors solve puzzles. Keep forms short, too. Every extra field lowers the number of people who finish.
Connect a form to a free service
Step 1 of 5
Sign up
Create a free account on a form service such as Formspree.
Create a form
Name it Website contact form. The service gives you an endpoint URL.
Paste the URL
Put the endpoint in your form's action attribute and set method to post.
Test it
Submit a test message from your live site and check your inbox.
Set a redirect
In the service settings, add your thank you page URL.
Try it: finish the form
This form is missing labels, types, and a submit button. Complete it using the example above.
Live preview
Quick quiz
Common mistakes
- Asking for too much. Ask only what you need to reply.
- No confirmation. Visitors resubmit or give up.
- Never testing the live form. A wrong endpoint silently loses leads.
Your action
Tick each item when you can do it. Your progress saves on this device.
Key terms
- Form service
- A tool that receives form data for static sites.
- Endpoint
- The URL that receives submitted data.
- Honeypot
- A hidden field that traps bots.
- Thank you page
- The page shown after a successful submission.
- Conversion
- A visitor completing a goal, like sending a form.
Questions beginners ask
Should I use reCAPTCHA?
Try a honeypot first. Add a CAPTCHA only if spam continues, since it adds friction.
Can I track form submissions in GA4?
Yes. Track visits to the thank you page as a conversion.
Is it safe to put my email in the action?
Do not use mailto: as an action. It is unreliable. Use a service.
Related lessons
Need a website built or fixed while you practice? The team at Remar Digital can help.