diff options
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 = ""; + } +} |
