Use updateOn: 'blur' in Angular Reactive Forms

后端 未结 1 1476
小鲜肉
小鲜肉 2020-12-18 19:01

I would like to start the validation of the fields of my forms only when the user leave the field (onblur).

I\'m trying in this way:



        
相关标签:
1条回答
  • 2020-12-18 19:48

    Set params as AbstractControlOptions

        firstName: ['initial value',{
             validators: [Validators.required, Validators.minLength(2), forbiddenNameValidator(/bob/i)],
             asyncValidators: [forbiddenNameValidatorAsync()],
             updateOn: 'blur'
        }],
    

    Example here https://stackblitz.com/edit/angular-hdna17?file=src%2Fapp%2Fhello.component.ts

    0 讨论(0)
提交回复
热议问题