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} />