Angular2 - Only Allow Alpha Characters TO Be Entered In An Input
Angular Reactive Form Validation - To accept only alphabets and space.
firstName: [
'',
[
Validators.required,
Validators.maxLength(50),
Validators.pattern('^[a-zA-Z ]*$')
]
],
My fix was to do it in my component
firstName: ['', Validators.pattern('^[a-zA-Z \-\']+')],
You need to use following to make pattern work
<input mdInput [(ngModel)]="details.firstName" placeholder="First name(s)" [pattern]="'^[a-zA-Z \-\']$'">