Angular 2 : Validators.pattern() not working

前端 未结 8 2150
醉酒成梦
醉酒成梦 2020-12-08 19:54

I am trying to validate input type=\"text\" using a pattern. I want text only.

Component :

 this.from = this.fb.group({
  name: [\'\',[         


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 20:05

    Pass pattern as string, without / which are the delimiters for regex

    Validators.pattern('^[a-zA-Z]+$')
    

提交回复
热议问题