i am trying to validate input type="text" using pattern , i want only text.
Component :
this.from = this.fb.group({
name: ['',Validators.required,Validators.pattern('^[a-zA-Z]+$')],
});
Html :
<input type="text" formControlName="name"/>
I have have also tried :
this.from = this.fb.group({
name: ['',Validators.required,Validators.pattern(/^[a-zA-Z]+$/)],
});
with no effect. Angular 4
requiredis useless since your pattern must match at least 1 character (the plus sign)