AngularJS supports client-side form validation. AngularJS keeps tracks of all the form and input field and it also stores the information about whether anyone has touched or modified the field or not.
Let’s See the two different class ng-dirty and ng-pristine that are used for form validation
- ng-pristine: The ng-pristine class tells that the form has not been modified by the user. This returns true if the form has not been modified by the user.
Return Boolean True if the form/input field is not modified by the user else it returns False.
- ng-dirty: The ng-dirty class tells that the form has been made dirty (modified ) by the user. It returns true if the user has modified the form.
Return Boolean True if the form/input field is modified by the user else it returns False.
Difference between ng-pristine and ng-dirty:
The main difference between both of them is that ng-dirty is used to tell that the input field is modified by the user and the ng-pristine is used to tell us that the field is untouched by the user.
Let’s see with the help of a small example to clear out everything.
- Difference between NodeJS and AngularJS
- Difference between Angular and AngularJS
- Difference between VueJS and AngularJS
- What is the Difference between Constructor and ngOnInit in AngularJS ?
- What is the difference between $watch and $observe in AngularJS ?
- Difference between declarations and entryComponents in AngularJS
- Difference between ng-container and ng-template in AngularJS
- Difference between Directive and Component in AngularJS
- Difference between Template and TemplateURL in AngularJS
- Difference between Bootstrap and AngularJS
- How to share data between controllers in AngularJS ?
- How to set, get and clear cookies in AngularJs?
- AngularJS vs Angular2 | Features and Comparison
- How to iterate over the keys and values with ng-repeat in AngularJS ?
- Interesting Facts and Features about AngularJS
- AngularJS Interview Questions and Answers
- How to Set navbar active class with Bootstrap and AngularJS ?
- How to add Google map and Marker to your Application using AngularJS ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.