Building an enquiry form in HTML 4.01
An enquiry form should ask only for information needed to answer the enquiry. Build a working server submission first, then add presentation and optional client-side checks. Visitors should be able to complete the same task with scripting disabled.
Choose a short set of fields
Separate the contact address from the message and explain which fields are required in text. Do not demand a postal address when an email reply will do. Give each control a name for submission and a unique id for its label. A label’s for attribute should match that id; placing words beside a box does not create the association.
Group related choices
Put related radio buttons inside a fieldset with a short legend. Use the same name for the buttons in one mutually exclusive group and different values for its choices. Arrange the source in the order people should complete it. Avoid a complicated tabindex sequence that must be rewritten whenever another field is added.
Validate on the server
Set the form method to POST for sending an enquiry. Check field presence, length and expected format after submission, even if JavaScript already checked them. Treat hidden fields as visitor input too. Use a fixed recipient address in the mail script and reject line breaks in values used in mail headers. POST alone does not encrypt the connection.
Return a usable correction page
When validation fails, name the affected fields near the beginning of the returned page and repeat the problem beside each control. Preserve valid entries, escaping their values for the HTML context before rendering them. Do not echo submitted markup directly into the page. Leave the visitor with an obvious way to correct and resubmit the form.
Exercise the failure cases
Try an empty submission, an apostrophe in a name, an ampersand in the message, an overlong enquiry and an invalid reply address. Test keyboard operation and a browser with scripts disabled. Simulate a failure to hand the message to the mail service; a success page should describe what the server actually accepted, without promising that an email has reached its recipient.
Document who receives enquiries and who checks failures. A technically working form still needs an attended destination and an alternative contact route.