0

I have password and confirmPassword fields that are built using FormBuilder:

public createAccountForm: FormGroup;

constructor(
     private builder: FormBuilder,
) 

this.createAccountForm = this.builder.group({      
  pass: this.builder.control('',
    [
      Validators.required
    ]),
  confirmPass: this.builder.control('',
    [
      Validators.required,
      CustomValidators.equivalent('pass')    // the custom validators checks if pass and confirmPass is the same
    ]),
    .............
});

----------------------

<input formControlName="pass" [(ngModel)]="model.pass" >
<input formControlName="confirmPass" >

This works OK. Now, I want to invoke the CustomValidators.equivalent('pass') when I change the pass input field.

How to do that?

Adriaan
  • 17,081
  • 7
  • 36
  • 71
rjuy
  • 11
  • 3
  • I would do something like presented here: https://stackoverflow.com/questions/43487413/password-and-confirm-password-field-validation-angular2-reactive-forms – AT82 Apr 28 '22 at 07:15

0 Answers0