From b9c1614a2b976fb9342b2b4ace2571aa5943d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Tue, 12 Dec 2023 09:53:16 +0100 Subject: [PATCH] Ajout code ts pour reset les invalid input quand on tape dedans --- ts/base/common.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ts/base/common.ts b/ts/base/common.ts index f1dedb5..5036ec0 100644 --- a/ts/base/common.ts +++ b/ts/base/common.ts @@ -65,3 +65,22 @@ document.addEventListener("DOMContentLoaded", function () { }); } }); + +// * Input Validation. +document.addEventListener("DOMContentLoaded", function () { + document.querySelectorAll("input.is-invalid").forEach((input) => { + let timer: NodeJS.Timeout|null = null; + input.addEventListener("input", () => { + if (timer) { + clearTimeout(timer); + } + timer = setTimeout(() => { + const parent = input.parentElement; + input.classList.remove("is-invalid"); + if (parent && parent.classList.contains("is-invalid")) { + parent.classList.remove("is-invalid"); + } + }, 250); + }); + }); +});