Angular 4 : Validators.pattern() not working

Discussão em 'Angular' iniciado por IntoTheDeep, Setembro 17, 2025.

  1. IntoTheDeep

    IntoTheDeep Guest

    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

    Continue reading...

Compartilhe esta Página