1

I have an issue of triggering an error in a input form, if other form field is changed.

myFormGroup = new FormGroup({
            'name': new FormControl('', [ Validators.required ]),
            'material': new FormControl('', [ Validators.required, NumberValidator.isaNumber ]),
            'prefix': new FormControl('', [ ]),
        });

I want to alert the user to enter prefix field only when he changes the material field. Can someone help me with this.

Thank you

  • found a solution myvalidators(control: FormGroup): ValidationErrors { if ((control.get('material').dirty && control.get('Prefix').value === '')) { return { 'prefix': true }; } return null; } – RamakanthReddy Kowdampalli Jun 12 '18 at 07:27

0 Answers0