How do you add validation to a reactive form?

Angular forms · Freshers

Model answer

Give each control validators when you create it: new FormControl('', [Validators.required, Validators.email]). Built-in validators include required, minLength, maxLength, min, max, pattern and email. In the template, check the control's state, for example show the error only when it is invalid and touched.

You can also disable the submit button while the form is invalid, but always validate again on the server.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions