I am developing a User Form.
I am summarizing my issue, if the user ticked on medical policy checkbox then user have to fill the medical policy detail.
user form group code below:
let userForm = this.myFormBuilder.group({
userName: ['',Validators.required],
password: ['',Validators.required],
isMedicalPolicy: [false],
medicalPolicyInfo: this.myFormBuilder.group({
policyNumber: ['',Validator.maxLength(10)], // how to apply conditional required validation here,
if is isMedicalPolicy value is true.
});
});
Please help on this.
isMedicalPolicyfield value and then alter the validation of the other fields.