I need help to confirm email and password

Hello I have a form which requests mail, confirm mail, password and confirm password. I currently control a simple validation that is with the formbuilder.group which makes it required. I want to be able to confirm the email and the password

export class RegisterPage {
  form: FormGroup;

  constructor(fb: FormBuilder) {
    this.form = fb.group({
      'pwd1': ['', Validators.required],
      'pwd2': ['', Validators.required]
    }, {validator: RegisterPage.passwordsMatch});
  }

  static passwordsMatch(cg: FormGroup): {[err: string]: any} {
    let pwd1 = cg.get('pwd1');
    let pwd2 = cg.get('pwd2');
    let rv: {[error: string]: any} = {};
    if ((pwd1.touched || pwd2.touched) && pwd1.value !== pwd2.value) {
      rv['passwordMismatch'] = true;
    }
    return rv;
  }
}
4 Likes

error man

1 Like

Edited, see if that works. That code was a collage from a couple of different validators that had differing types for that return value.

works great, just edit the variables and done!

You can also check this repo which is an Ionic 3 example app to learn how to handle Forms and Validations and has a Password (and confirmation) example: https://github.com/ionicthemes/ionic2-form-handling-and-validations
Hope it helps :wink:

and how to message it to view page?

Sorry, but I have no clue what that means at all.