Allow HTML validation messages

This commit is contained in:
Florine W. Dekker 2022-11-20 22:03:00 +01:00
parent 9beda27c23
commit 6f15754c50
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
1 changed files with 6 additions and 6 deletions

View File

@ -34,10 +34,10 @@ export function showMessageType(card: HTMLElement | HTMLFormElement,
if (message == null || type == null) { if (message == null || type == null) {
card.classList.add("hidden"); card.classList.add("hidden");
output.innerText = ""; output.innerHTML = "";
} else { } else {
card.classList.add(type); card.classList.add(type);
output.innerText = message; output.innerHTML = message;
} }
} }
@ -110,7 +110,7 @@ export function clearInputValidity(input: HTMLInputElement): void {
hint.classList.remove("valid", "invalid"); hint.classList.remove("valid", "invalid");
hint.role = null; hint.role = null;
hint.innerText = hint.dataset["hint"] ?? ""; hint.innerHTML = hint.dataset["hint"] ?? "";
} }
} }
@ -137,7 +137,7 @@ export function showInputInvalid(input: HTMLInputElement, message?: string): voi
input.setAttribute("aria-errormessage", hint.id); input.setAttribute("aria-errormessage", hint.id);
hint.role = "alert"; hint.role = "alert";
hint.innerText = message; hint.innerHTML = message;
} }
} }
@ -161,7 +161,7 @@ export function showInputValid(input: HTMLInputElement, message?: string): void
if (hint != null) { if (hint != null) {
hint.classList.add("valid"); hint.classList.add("valid");
if (message != null) hint.innerText = message; if (message != null) hint.innerHTML = message;
} }
} }
@ -185,6 +185,6 @@ doAfterLoad(() => {
$a("input + small[data-hint]").forEach((hint: Element) => { $a("input + small[data-hint]").forEach((hint: Element) => {
if (!(hint instanceof HTMLElement)) return; if (!(hint instanceof HTMLElement)) return;
hint.innerText = hint.dataset["hint"] ?? ""; hint.innerHTML = hint.dataset["hint"] ?? "";
}); });
}); });