30 seconds of angular
Star
✨✨ New to Angular? Check out interactive Angular Codelab ✨✨

Mark reactive fields as touched

Here is the way to notify user that there are fields with non-valid values.

markFieldsAsTouched function FormGroup or FormArray as an argument.

  function markFieldsAsTouched(form: AbstractControl): void {
        form.markAsTouched({ onlySelf: true });
        if (form instanceof FormArray || form instanceof FormGroup) {
          Object.values(form.controls).forEach(markFieldsAsTouched);
        }
      }
    

Links

Bonus

It's very useful to check out more general method Accessing all nested form controls by Thekiba to work with controls.