I am facing a simple issue with my reactive form and validations. My goal is to have the button disabled until the form group is valid.
Even though I thought I had the solution by using [disabled]="!fg_profile", the button remains enabled. When checking the console output upon clicking the button, it shows that the formgroup is invalid (false), yet the button stays enabled...
<button type="button" class="btn btn-primary pull-right"
(click)="updateProfile(fg_profile.value)"
[disabled]="!fg_profile">{{'control.save' | translate }}</button>
Here is my button code.
this.fg_profile = this.fb.group({
password: [null, [Validators.minLength(6)]],
password_confirm: [null, [Validators.minLength(6)]],
email: [null, [emailValidator, Validators.minLength(6)]],
jabber: [null, [emailValidator, Validators.minLength(3)]],
current_password: [null, [Validators.required, Validators.minLength(6)]]
},
{
// check whether our password and confirm password match
validator: PasswordValidation.passwordMatchValidator
});
This is my validation logic in TypeScript.
Despite trying [disabled]="true" as well, the button remains enabled. What could be causing this issue?