AngularJS Form Validation CSS Classes


Example

Angular also provides some CSS classes for forms and inputs depending on their state

ClassDescription
ng-touchedField has been touched
ng-untouchedField has not been touched
ng-pristineField has not been modified
ng-dirtyField has been modified
ng-validField is valid
ng-invalidField is invalid

You can use these classes to add styles to your forms

input.ng-invalid {
  background-color: crimson;
}
input.ng-valid {
  background-color: green;
}