I have an input with a type number which allows by default the insert of some characters like '+' '-' '.'
HTML
<input type="number"
class="form-control"
formControlName="numberChildren"/>
TypeScript
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.createForm();
}
private createForm(): void {
this.personalForm= this.formBuilder.group({
numberChildren: [null, [Validators.required, Validators.pattern('[0-9]{2}')]],
})
}
I want to implement a logic which accept only numbers without '+' '-' '.'
Note: it is mandatory to use number as type of the input