Files
mareike/app/Views/Components/NumericInput.vue

18 lines
361 B
Vue

<!-- NumericInput.vue -->
<script setup>
const model = defineModel() // bindet v-model automatisch
</script>
<template>
<input
type="text"
:value="model"
@input="model = $event.target.value.replace(/[^0-9]/g, '')"
@keypress="($event) => {
if (!/[0-9]/.test($event.key)) {
$event.preventDefault()
}
}"
/>
</template>