Accepting selected projects for Q2 2024 Check availability →
SERVER 02SYSTEM ONLINELAST SYNC: 03:17:44RSS 2.0 — ONLINE
HALF ASSEDTECHNICAL NOTES_
EST. 1999ISSUE 04.2BEST VIEWED AT 1024 × 768
TECHNICAL NOTES / PRACTICAL GUIDES / HTML & FORMS / RECORD 6c5f6f
[HTML & FORMS]GUIDE

Building an enquiry form in HTML 4.01

POSTED: 14.12.2000AUTHOR: ADMIN3 MIN READCOMMENTS: 0

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.

HANDOVER

Document who receives enquiries and who checks failures. A technically working form still needs an attended destination and an alternative contact route.

References

W3C: HTML techniques for WCAG 1.0, November 2000

W3C: HTML 4.01 forms