diff options
| author | Joe Carstairs <me@joeac.net> | 2025-12-18 11:04:03 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2025-12-18 11:04:03 +0000 |
| commit | 46c9b7731622f1f4d0f6a03c3179e747e0ce065d (patch) | |
| tree | 71c60d9cf72797b06054a61990f7baa41db2e8a0 /website/src/scripts/contact/post-error-message.ts | |
| parent | 40d6c7f248c3fe506690ee3ccb3894f952e164ed (diff) | |
contact page
Diffstat (limited to 'website/src/scripts/contact/post-error-message.ts')
| -rw-r--r-- | website/src/scripts/contact/post-error-message.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/website/src/scripts/contact/post-error-message.ts b/website/src/scripts/contact/post-error-message.ts new file mode 100644 index 0000000..9846635 --- /dev/null +++ b/website/src/scripts/contact/post-error-message.ts @@ -0,0 +1,30 @@ +import type { Selectors } from "./selectors"; + +export function postErrorMessageOnContactForm( + { contactForm }: Selectors, + errorMsg: string, +) { + const errorElem = contactForm.errorElem(); + if (errorElem) { + errorElem.textContent = errorMsg; + errorElem.removeAttribute("hidden"); + } else { + alert(errorMsg); + } +} + +export function postErrorMessageOnOtpForm( + { otpDialog }: Selectors, + errorMsg: string, +) { + const errorElem = otpDialog.errorElem(); + if (errorElem) { + errorElem.textContent = errorMsg; + errorElem.removeAttribute("hidden"); + } else { + alert(errorMsg); + } + for (const input of otpDialog.allOtpInputs()) { + (input as HTMLInputElement).value = ""; + } +} |
