I have an Angular 8 application. What I wanna do is not letting user to set any other value in number input, than from range of 0-100
I was thinking something like this
<input type="number" [ngModel]="value" (ngModelChange)="validateValue($event)">
and
value = 100;
validateValue(event: number) {
if (event > 100) {
this.value = 100;
} else if (event < 0) {
this.value = 0;
} else {
this.value = event;
}
}
When there is a 100 and I delete last digit and write 5 (so now I should have 105), it will do the magic and change the value to 100.
When I cursor select the whole number and write for example 105, it will do the magic too.
However. when I use the step arrows, or cursor select the last digit and change the last digit, the magic isn't happening.
Why is this not working ?