material input field code example
Example 1: mat input formatter tel
ngOnInit() {
let MOBILE_PATTERN = /[0-9\+\-\ ]/;
this.emailForm = new FormGroup({
PhoneNumber:new FormControl('',[Validators.pattern(MOBILE_PATTERN)])
});
}
Example 2: mat-form-field email validation
<input matInput placeholder="Favorite food" [(ngModel)]="enterEmail" name="myEmail" pattern="[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}" required>