based on previous make validation for required in reactive forms

The solution for “based on previous make validation for required in reactive forms” can be found here. The following code will assist you in solving the problem.

this.userCustomForm.get(‘age’).valueChanges.subscribe(val => {
if (condition) {
this.userCustomForm.controls[‘licenseNo’].setValidators([Validators.required]);
} else {
this.userCustomForm.controls[‘licenseNo’].clearValidators();
}
this.userCustomForm.controls[‘licenseNo’].updateValueAndValidity();
});

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in