From c010bbaff0c67208cdcc0f668fbdc1b6e929ff48 Mon Sep 17 00:00:00 2001 From: Moritz Utcke Date: Thu, 25 Sep 2025 11:41:28 -0400 Subject: [PATCH] =?UTF-8?q?Fl=C3=A4che=20darf=20nur=20noch=20Integer=20sei?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Ausweis/GebaeudeDaten.svelte | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/components/Ausweis/GebaeudeDaten.svelte b/src/components/Ausweis/GebaeudeDaten.svelte index f06764b5..e2ac4557 100644 --- a/src/components/Ausweis/GebaeudeDaten.svelte +++ b/src/components/Ausweis/GebaeudeDaten.svelte @@ -11,6 +11,22 @@ export let objekt: ObjektClient; export let ausweisart: Enums.Ausweisart; + + function onlyAllowIntegerInput(event: KeyboardEvent) { + const charCode = event.which || event.keyCode; + // Allow only numbers (0-9) and control keys (e.g., backspace) + if (charCode < 48 || charCode > 57) { + event.preventDefault(); + } + } + + function onlyAllowPastingIntegers(event: ClipboardEvent) { + const clipboardData = event.clipboardData || (window as any).clipboardData; + const pastedData = clipboardData.getData("Text"); + if (!/^\d+$/.test(pastedData)) { + event.preventDefault(); + } + }
@@ -125,6 +143,8 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8 type="number" step="1" required + on:keypress={onlyAllowIntegerInput} + on:paste={onlyAllowPastingIntegers} bind:value={aufnahme.nutzflaeche} />