matching password ionic 5 code example

Example: new password confirm password validation in ionic 5

<ion-item class='form-text error' *ngIf="userForm.controls.password.touched && !userForm.controls.password.valid">
        <ion-label no-margin stacked wrap-text>Password must be between 6 and 12 characters with at least one capital letter, one small letter, and one digit.</ion-label>
      </ion-item>
      <ion-item>
        <ion-label stacked>Re-enter Password</ion-label>
        <ion-input type="password" [(ngModel)]="confirmPassword" formControlName="confirmPassword"
                   required show-password></ion-input>
      </ion-item>
      <ion-item class='form-text error' *ngIf="userForm.controls.confirmPassword.touched && userForm.hasError('mismatchedPasswords') && userForm.controls.password.valid">
        <ion-label no-margin stacked>Passwords do not match</ion-label>
      </ion-item>

Tags:

Misc Example