I have an input field that I validate @blur
.
The goal is to allow 9 numbers grouped per 3 and a dot after, for example:
123456789
this should be masked to 123.456.789
But it should be possible too for the user to type 123.456.789
himself.
This is what I've got so far, I force the user to type 123.456.789
<input
@blur="validateNumber($event.target.value)"
>
validateNumber(value) {
if (/^(\d{3}\.){2}\d{3}$/.test(value)) {
this.validNumber = true;
return;
}
this.validNumber = false;
return;
}
I need a way to allow 123456789
and to make it 123.456.789