About
I am trying to compare the value of password and confirm password and if found mismatch then message to be shown.
Due to some reasons it shows nothing. Am I missing anything in below code?
Form Group Validation work
this.resetPasswordForm = new FormGroup({
password: new FormControl("", [
Validators.required,
Validators.minLength(8),
Validators.maxLength(40)
]),
password_confirmation: new FormControl("", [
Validators.required
]),
});
Html
<input type="password" formControlName="password_confirmation" />
<span *ngIf="resetPasswordForm.controls.password_confirmation.errors
&& resetPasswordForm.controls.password_confirmation.dirty
&& resetPasswordForm.controls.password_confirmation.touched">
<ng-container *ngIf="resetPasswordForm.controls.password_confirmation.errors.required;else second">
Confirm password is required
</ng-container>
<ng-template #second>
<ng-container *ngIf="resetPasswordForm.controls.password_confirmation.value
== resetPasswordForm.controls.password.value">
Password and confirm password mismatch
</ng-container>
</ng-template>
</span>
password_confirmationhas onlyValidators.required.resetPasswordForm.controls.password_confirmation.errorswill be false when this field has some value.