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