I need help to confirm email and password


#1

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


#2
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;
  }
}

Password and confirm password validation
#3

error man


#4

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


#5

works great, just edit the variables and done!


#6

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: