Reactive Forms - mark fields as touched

后端 未结 19 1574
旧时难觅i
旧时难觅i 2020-12-04 23:15

I am having trouble finding out how to mark all form\'s fields as touched. The main problem is that if I do not touch fields and try to submit form - validation error in not

19条回答
  •  星月不相逢
    2020-12-04 23:50

    From Angular v8, you have this built-in with the help of the markAllAsTouched method.

    As an example, you could use it like

    form.markAllAsTouched();
    

    See the official doc : https://angular.io/api/forms/AbstractControl#markallastouched

提交回复
热议问题