Use updateOn: 'blur' in Angular Reactive Forms

Viewed 29444

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:

    this.profileForm = this.fb.group({
                firstName: ['initial value',
                    [Validators.required, Validators.minLength(2), forbiddenNameValidator(/bob/i)],
                    [forbiddenNameValidatorAsync()],
                    { updateOn: 'blur' }
                ],
                lastName: ['b']
            });

But in this way it does not work. The validations (sync and async) are performed during onChange.

I would also like to ask how you can verify the name by making checks on the lastName.

Example: I would like the name field to be disabled if it is the same as the last name (only name field, not entire form not both fields).

1 Answers
Related