Show Validation Message on submit in Angular 4 Reactive Forms

℡╲_俬逩灬. 提交于 2019-12-03 16:15:47

Something like

onSubmit() {
    console.log(this.signupForm)
    this.signupForm.controls['firstname'].markAsTouched()
}
Ankit Prajapati

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!