Angular 4 Mobile number validation
just add validators pattern
mobileNumber: new FormControl(null, [Validators.pattern("[0-9]{0-10}")])
and the type will be number and it will avoid accepting any character
<input type="text" (keypress)="keyPress($event)" minlength=10 maxlength=10>
keyPress(event: any) {
const pattern = /[0-9\+\-\ ]/;
let inputChar = String.fromCharCode(event.charCode);
if (event.keyCode != 8 && !pattern.test(inputChar)) {
event.preventDefault();
}
}