I have a registration component in which i created form articleForm
export class RegistrationComponent implements OnInit {
articleForm = new FormGroup({
password: new FormControl('', [Validators.required]) ,
confirmPassword: new FormControl ('',[ Validators.required])} ,
this.checkPasswords
);
checkPasswords(group: FormGroup) {
let setPassword = group.get('setPassword').value;
let confirmPassword = group.get('confirmPassword').value;
return setPassword === confirmPassword ? null : { notSame: true }
}
here is my html file ......
<tr><td> Password</td><td><input formControlName="password" id="materialFormCardNameEx" class="form-control"type="password">
<label *ngIf="articleForm.get('password').invalid && processValidation" [ngClass] = "'error'"> <font color="red"> password is required. </font></label>
<tr><td>confirm Password</td><td><input formControlName="confirmPassword" id="materialFormCardNameEx" class="form-control" type="password">
<label *ngIf="articleForm.get('confirmPassword').invalid && processValidation" [ngClass] = "'error'"> <font color="red"> password not matching. </font></label>
how to do a confirm password validation in this?,
how to do it with formgroup instead of formbuilder? coz there are many solution with form builder but none with form group