Adding validations to the registration form

Before submitting any form, we need to validate whether the input entered by the user is correct or not. To apply the validation on the forms, Angular provides the following validation directives, we can also build our custom validators:

  • required: Marks a control to have a non-empty value
  • minlength: Applies minimum length validation
  • maxlength: Applies maximum length validation
  • pattern: Validates a control value to match a regex

Based on the input validity, validation directives change the state of the ngModel, ngModelGroup, and ngForm, we can access them using their template reference variables. Let us use the Angular validation directives to apply validation on our form controls. To demonstrate ...

Get Building Modern Web Applications using Angular now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.