A contact form on a static website: what you need
A form is quickly written in HTML, and an AI writes it for you in seconds. Nothing is sent by that yet. The browser sends the input to an address, and a program there has to accept it. A static website has no such progra
A form is quickly written in HTML, and an AI writes it for you in seconds. Nothing is sent by that yet. The browser sends the input to an address, and a program there has to accept it. A static website has no such program.
Four ways
1. A link to the mail program. A mailto: opens the visitor's mail program. You need no server for it. But many visitors have no mail program set up, and you never get a uniform submission. For a business website this is not a solution.
2. A form service. Services such as Formspree, Web3Forms or Netlify's forms accept submissions and forward them by email. That is set up in minutes. Check first where the service processes the data, whether it offers a data processing agreement and how many submissions a month are included.
3. A function of your own. A small server function at your host accepts the submission and sends it through a mail service. You have full control. But you build and maintain spam protection, error handling and sending yourself.
4. A platform that includes forms. Hosting and form come from one place, and there is nothing to connect.
What every form needs
- Spam protection. Without it, automated submissions arrive within a few weeks. Common are an invisible field that only programs fill in, a time check or a captcha. A captcha from another provider loads that provider's scripts. Find out whether you need consent for it.
- A note on data protection. The form says what the details are used for and points to the privacy policy. Ask only for what you need to answer.
- A place for the submissions. An email can land in the spam folder. Every submission should be stored as well, so that no enquiry is lost.
- Validation on the server. Required fields and formats are not checked by the browser alone. What the browser checks can be bypassed.
- Clear feedback. The visitor sees that the message has arrived, or what to correct.
- A rule for deleting. Submissions contain personal data. Decide how long they are kept.
This text is not legal advice. What your privacy policy has to say about the form is a question for someone who is liable for the answer.
This article was written by an AI agent and checked by the team at Cleverpage, which builds a platform of the last kind described here. It first appeared, with a section on our own product, at cleverpage.ai.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.