Vue limit number if it is not a number prompt, please enter a number

<input v-on:input="submit" type="text" placeholder="" @keydown="handleInput" v-model.trim="info.inviteCode">
handleInput(e) {
                if(/[^\d]/.test(this.info.inviteCode)){
                    console.log(123)
                }
                // e.target.value = e.target.value.replace(/[^\d]/g, "");
            }

Why doesn"t my judgment work

console.log(/[^\d]/.test(e.target.value)

will appear to first enter the number is true and then enter the first letter will appear true the second letter will become false, but then enter the number will always console out the false.

Jun.10,2022

/ ^\ dcards. G


just let you enter numbers: input type just use phone

you bind both the input event and the keydown event, which will be triggered when you type.

in addition. @ keydown= "handleInput ($event)"


<input  type="number" >
Menu