I need to block the 'e' value that I can put in a input type number so this is my html file:
<input type="number" class="form-control" [(ngModel)]="money" name="money" required min="0" step="0.01" >
in my ts class
money:number;
Anyone can help me? I want block the possibility to insert the value 'e' in input type number.
You can use the keypress
event on the input to prevent the entering of e
. You'll have to create a method as a handler on your Component Class.
try this:
preventE(event) {
if (event.which === 101) {
event.preventDefault();
}
}
Template:
<input
type="number"
class="form-control"
[(ngModel)]="money"
name="money"
required
min="0"
step="0.01"
(keypress)="preventE($event)">