Building in practice
A language switch should not erase a carefully written question
A bilingual inquiry form needs a session draft reconciled across language changes, refreshes and browser history, with only the submitted version cleared after confirmation; IANNIL preserves original input and blocks language navigation when a storage failure could lose it.
IANNILPublished Updated
Decisions and supporting pages
| Topic | Current approach | Source |
|---|---|---|
| Language change | Translate untouched templates; preserve the visitor’s writing exactly. | View source |
| Browser history | Distinguish cached restoration from ordinary history navigation and reconcile the current draft. | View source |
| Explicit clear | Returning to an older page must not restore deleted personal fields. | View source |
| An earlier request succeeds | Clear only the submitted version and keep edits made while waiting. | View source |
| Saving fails | Keep visible input, explain the failure and stop language navigation that could lose it. | View source |
Someone who opens an inquiry form and carefully describes a project has already done useful work. They may have organized the team’s context, previous attempts and the point where progress stopped. To the website, it is a string. To the person writing, it is time spent making a problem understandable.
A language switch should not replace that work with a default template. Yet this was what we observed on our contact page: entry parameters survived the navigation, while the visitor’s own writing did not.
Preserve the question before thinking about sending it
We first stored name, email, message, purpose and service choice as a draft in the current tab’s session. A refresh or language change could then restore the same entry context, preserving spaces and line breaks exactly.
A default template and a visitor’s writing need different treatment. An untouched template can be translated. Once someone changes it, even by adding whitespace, we should not replace it as though it were still our blank outline. Template ownership and readiness to submit are separate decisions.
We chose sessionStorage instead of keeping personal information long term. Browser session recovery may still retain the draft, so the page explains that and offers Clear draft. A new course or pricing entry takes precedence over an incompatible old draft, keeping the visitor’s fresh choice intact.
The Back button exposed the next problem
Initial language-switch and refresh checks passed, as did the focused automated tests. Then we tried one more sequence: write A in English, switch to Chinese, change it to B and press Back.
The page still showed A. Switching languages again could save that stale value over B. Autosave had preserved a record without ensuring that the returning page displayed its latest version.
Our first fix handled a document restored from the browser cache. A rebuilt preview still reproduced the failure. An ordinary history navigation can also restore form fields, after the page script initializes. The script had read B, and the browser subsequently put A back into the controls.
The final implementation distinguishes those paths. A cached return reconciles the draft. An ordinary history return waits for native field restoration before adopting the current record. If someone cleared the draft on another page, returning to an older page must not resurrect their name or email either.
A successful response also belongs to a moment in time
Consider a visitor who sends a message, then adds a sentence while the network request is still pending. Success for the earlier request does not mean that the new sentence was sent.
Success should therefore clear only the draft version that was submitted. New writing must remain. Even clearing a draft and rewriting identical text creates a later edit; matching strings alone cannot identify the same submission.
Looking at one successful result page will not reveal this timing problem. We tested newer edits, older responses, explicit clears and history restoration together to examine what happens when they overlap.
Failure feedback should explain the next step
A warning at the bottom of a page is easy to miss when someone clicks a language link at the top and nothing happens. The blocked-navigation explanation now scrolls into view and receives focus. An ordinary save failure while typing does not steal that focus.
Sending also needs precise language. Requests pass through Pages API validation, Turnstile and a Mail Worker. A successful API confirmation establishes a successful relay result, not that a recipient has received, read or promised to answer the message. Network errors should preserve the writing and explain that sending was not confirmed.
This work changed how we look at an ordinary contact form. Writing an inquiry is a process interrupted by navigation, language choices and waiting. Protecting what someone has already written begins well before the success message, and is easy to overlook.
Explore the current inquiry form · Read the draft and data notice
Try it yourself: four checks without sending mail
This repeatable checklist was added on 2026-10-09. Use a test name, visitor@example.test and example text. Do not enter real customer data or press Send. Start in a new tab to avoid overwriting an existing draft.
- Enter a test name, email and a two-line question on the Chinese contact page, switch to English, then refresh. Expected: your writing, spaces and line breaks remain, while interface labels change language.
- In English, end the question with “version B”. Switch to Chinese and replace it with “version C”, then press Back. Expected: the latest “version C”, not the cached earlier text.
- Choose Clear draft, then navigate Forward, Back and refresh. Expected: the previous test name, email and writing do not return. A default template may be shown again.
- Record the browser version, language path, action sequence, expected and actual results. Preserve this non-sensitive evidence if something fails, and clear the draft again when finished.
These steps cover page draft behavior only. Stale responses, denied storage, verification challenges and mail delivery require their own test conditions and are not established by this checklist.
Implementation details and verification notes
These technical notes record checks from 2026-10-08. Language switching, refresh, history navigation and explicit clearing were checked in a real browser. Storage denial, confirmed success and old-response races use simulations of the actual controller. No real message was sent or challenge completed.
Drafts stay in the browser session and exclude challenge tokens. On submission, Pages independently validates name, email, purpose and service, then forwards through the MAIL_WORKER binding. The Mail Worker calls EMAIL.send; failure returns send-failed / 502 with a fixed error log.
The browser requires a question and blocks unfinished templates. The API retains its legacy acceptance of an empty message, so frontend restrictions are not backend guarantees. Without scripts, drafts are not restored and ordinary form redirects may lose inputs; browsing with JavaScript disabled was not verified.
Protocol example · synthetic data, not a runnable request
The responses represent separate branches. The placeholder token cannot pass a real challenge; accepted only means the Worker returned success.
POST /api/contact
Accept: application/json
name=Example visitor
email=visitor@example.test
purpose=enterprise
service=
message=Example: define the scope and acceptance criteria.
_return=/contact
cf-turnstile-response=[test placeholder]
422 { "ok": false, "reason": "validation" }
403 { "ok": false, "reason": "verification" }
502 { "ok": false, "reason": "mail" }
200 { "ok": true, "reason": "accepted" } | Check | Result | Scope |
|---|---|---|
| Real local browser · 390 × 844 | Synthetic name, email and multiline writing survived Chinese → English, refresh and a return to Chinese. Selecting project_cohort retained fields and the expanded training purpose. Explicit clear worked. | No send action; no verification or delivery evidence. |
| Actual form controller tests · simulated environment | Both language directions/refresh, simulated history reconciliation and stale-response races, exact whitespace, template protection, denied/corrupt storage, API rejection, newer pending edits and clear races. The form/draft/i18n focused run passed 44 checks. | Actual production script, with simulated controls, storage and transport. |
| Backend tests · simulated external providers | Field lengths/email, mismatched purpose/service, escaped HTML and line breaks; rejected verification prevents relay; relay failure differs from acceptance; 429 and return-path allowlist. The backend focused run passed 39 checks. | Turnstile, service binding and EMAIL.send are mocks. The Worker provider-failure test uses a commerce request, not a real inquiry delivery experiment. |
Analytics events exclude names, emails, message bodies and query parameters; GA backend collection was not verified. These records do not establish client outcomes, conversion gains or real mail delivery. Paid services remain closed, with no enrollment, reservations, payment or promised reply deadline.
Frequently asked questions
Should a language change translate what a visitor has written?
This site replaces only untouched default templates. Edited names, email addresses and questions remain unchanged, including whitespace and line breaks. Template ownership and readiness to submit are separate decisions.
Does sessionStorage guarantee that a draft cannot be lost?
No. It serves the current tab session, may be unavailable, and may survive browser session recovery. The site explains the scope, offers clearing and preserves visible input with a warning when saving fails. It does not synchronize across devices.
Why can an old draft reappear after pressing Back?
The document may return from cache, or the browser may restore older form values after scripts initialize. This site handles those paths separately, reads the current draft again and avoids resurrecting deleted personal fields.
Can a success response erase changes made after sending?
This site clears a draft only when it matches the submitted version. Edits made while waiting remain. Clearing and rewriting identical text creates a new version too, so string equality alone is insufficient.
Does form success mean the mail was read or the service accepted?
No. Success means the API confirmed the relay result; it does not prove inbox delivery, reading, a reply or service acceptance. This article includes no real sending test and no verified browsing with JavaScript disabled.