I'm trying to create Angular 5 registration form with .NET Core.
I'm checking whether password and retyped password are the same in the registration form. I'm using FormBuilder for form.
But checking password1 and password2 is always failing. I have tried ===
also.
if (this.RegistrationForm.valid) {
if (this.RegistrationForm.get('password1') == this.RegistrationForm.get('password2')) {
this.MyService.Register(this.RegistrationForm.value).subscribe((data) => {}, error => this.errorMessage = error)
} else {
this.errorMessage = "cdscs";
}
}
constructor(private fb: FormBuilder, private MyService: RoadSignService) {
this.RegistrationForm = this.fb.group({
Id: 0,
name: ['', [Validators.required]],
email: ['', [Validators.required]],
gender: ['', [Validators.required]],
department: ['', [Validators.required]],
address: ['', [Validators.required]],
password1: ['', [Validators.required]],
password2: ['', [Validators.required]]
})
}