In reactive forms, you can use built-in validator like required and minlength on your input form controls. For example, the registration form can have these validators on name input field:
1 2 3 4 5 6 | this.registrationForm = new FormGroup({ 'name': new FormControl(this.hero.name, [ Validators.required, Validators.minLength(4), ]) }); |
Whereas in template-driven forms, both required and minlength validators available as attributes.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.