diff options
| author | Joe Carstairs <me@joeac.net> | 2026-06-04 15:15:02 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-06-04 15:16:34 +0100 |
| commit | 813836fbba884388e6013e9fd377430ef33b6c8d (patch) | |
| tree | 056149f5c51eabaa89960a7d8d2eb68fe9b158e8 /http/public/scripts/contact/post-error-message.js | |
| parent | fac1199cd61e069b1a144d2548477a2c3b3b94b0 (diff) | |
http: adds scripts
Diffstat (limited to 'http/public/scripts/contact/post-error-message.js')
| -rw-r--r-- | http/public/scripts/contact/post-error-message.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/http/public/scripts/contact/post-error-message.js b/http/public/scripts/contact/post-error-message.js new file mode 100644 index 0000000..121cbb6 --- /dev/null +++ b/http/public/scripts/contact/post-error-message.js @@ -0,0 +1,34 @@ +/** @typedef {import("./selectors.js").Selectors} Selectors */ + +/** + * @param {{contactForm: Selectors}} contactForm + * @param {string} errorMsg + */ +export function postErrorMessageOnContactForm({ contactForm }, errorMsg) { + const errorElem = contactForm.errorElem(); + if (errorElem) { + errorElem.textContent = errorMsg; + errorElem.removeAttribute("hidden"); + } else { + alert(errorMsg); + } +} + +/** + * @param {{otpDialog: Selectors}} otpDialog + * @param {string} errorMsg + */ +export function postErrorMessageOnOtpForm({ otpDialog }, errorMsg) { + const errorElem = otpDialog.errorElem(); + if (errorElem) { + errorElem.textContent = errorMsg; + errorElem.removeAttribute("hidden"); + } else { + alert(errorMsg); + } + /** @type NodeListOf<HTMLInputElement> */ + const inputs = otpDialog.allOtpInputs(); + for (const input of inputs) { + input.value = ""; + } +} |
