I need to restrict the user from entering numbers greater than 100.
The code snippet below represents a simplified version of my production code. However, I am facing an issue where the first keypress always shows an empty string result.
For example, if "101" is entered into the input field, the value of event.target.value
will show as "01".
How can I resolve this issue?
<v-text-field
type="number"
@keypress="formatNumber($event)"
>
</v-text-field>
formatNumber(event) {
console.log(event.target.value); // The first keypress returns an empty string
if (event.target.value > 100) {
event.target.value = null;
}
}