Show Validation Message on submit in Angular 4 Reactive Forms

前端 未结 3 2064
不思量自难忘°
不思量自难忘° 2021-02-09 01:39

I am using Angular 4, Reactive forms.I want to show validation error message when the user clicks on Submit/Create Account button. Here is the HTML and typescript code that I a

3条回答
  •  天命终不由人
    2021-02-09 02:07

    To get the properties like touched, dirty, valid of form control through formGroup use :

    signupForm.controls.firstname.touched. same way you can get the other properties like valid and invalid.

    if you have created individual object of FormControl then, you can access that object properties as firstname.touched without using formGroup.

    for more information about the validation in Model Driven Forms refer Model Driven Form Validations here.

提交回复
热议问题