fix(docs): keep converter forms usable after submitting - #65
Conversation
The submit buttons had no type, so they defaulted to type=submit and reloaded the page whenever the handler threw before writing its result. The handlers also wrote into the <form> element itself, replacing the input and button with the result text after a single conversion. Add type="button" to the three converter buttons and write results into a dedicated element. Also report invalid timezones and locales in lookuptimezonetime.html instead of failing silently. Closes ArjunSharda#64
|
The
Those three markup issues are small and worth fixing — I can open a separate PR for them, plus the |
Closes #64
Problem: as described in the issue, the three converter pages had two defects
that masked each other. The submit buttons had no
type, so they defaulted totype="submit"; and the handlers wrote their result into the<form>elementitself, wiping out the input and button after a single conversion.
Fix: added
type="button"to the three converter buttons, and gave each pagea dedicated
<p>for the result so the form survives. Inlookuptimezonetime.htmlan invalid timezone or locale madetoLocaleStringthrow — which is what exposed the submit defect — so that case now reports
"Invalid Date" instead of failing silently.
On the asymmetry between the three files: each page already handled errors
differently before this PR (
utcsecondstodatetime.htmlchecks for empty input,datetimetoutc.htmlrelies ontoUTCString()returning "Invalid Date"). I keptthose as they were and only added handling where something was actually broken,
to keep the diff focused. Happy to unify them if you'd prefer.
Tested locally on all three converters: repeated conversions without a
reload, empty input, invalid date, and invalid timezone. No page reloads and no
query strings appended in any case.