Form validation class

Description

When AngularJS is handling a form, it adds classes to the form based on the current state.

These classes are:

  • .ng-pristine {}
  • .ng-dirty {}
  • .ng-valid {}
  • .ng-invalid {}

When a field is invalid, the .ng-invalid class will be applied to the field.

Example

For example we can set the class as follows:


input.ng-invalid  {
   border:  1px  solid red;
}
input.ng-valid  {
    border:  1px  solid green;
}





















Home »
  AngularJS »
    AngularJS Tutorial »




Introduction
Buildin Filters
Buildin Directives