What's the difference between ng-pristine and ng-dirty in AngularJS ? Last Updated : 08 Nov, 2022 Comments Improve Suggest changes Like Article Like Report AngularJS supports client-side form validation. AngularJS keeps track of all the form and input fields and it also stores the information about whether anyone has touched or modified the field or not. The two different classes ng-dirty and ng-pristine that are used for form validation, are described below: 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 type: 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 type: Return Boolean True if the form/input field is modified by the user else it returns False.Example 1: This example describes the usage of the ng-pristine and ng-dirty classes in AngularJS by implementing it using the <input> element. HTML <!DOCTYPE html> <html> <head> <title> Difference between ng-pristine and ng-dirty </title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"> </script> <style> body { font-family: Arial; text-align: center; } h1 { color: green; } </style> </head> <body> <h1 style="color:green">GeeksforGeeks</h1> <h3>ng-pristine and ng-dirty in AngularJS</h3> <form ng-app="" name="myForm"> <input name="email" ng-model="data.email"> <div class="info" ng-show="myForm.email.$pristine"> Now Pristine </div> <div class="error" ng-show="myForm.email.$dirty"> Now Dirty </div> </form> </body> </html> Output: Example 2: This example describes the usage of the ng-pristine and ng-dirty classes in AngularJS by implementing it using the <textarea> element. HTML <!DOCTYPE html> <html> <head> <title> Difference between ng-pristine and ng-dirty </title> <script src= "https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"> </script> <style> body { text-align: center; font-family: Arial; } h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h3> ng-pristine and ng-dirty in AngularJS</h3> <form ng-app="" name="myForm"> <textarea name="text" ng-model="data.text"></textarea> <p class="info" ng-show="myForm.text.$pristine"> Now Pristine. </p> <p class="error" ng-show="myForm.text.$dirty"> Now Dirty </p> </form> </body> </html> Output: Difference between ng-pristine and ng-dirty: The main difference between them is that the ng-dirty is used to tell that the input field is modified by the user, whereas the ng-pristine is used to tell us that the field is untouched by the user. Comment More infoAdvertise with us Next Article What's the difference between ng-pristine and ng-dirty in AngularJS ? cybercreed010 Follow Improve Article Tags : Web Technologies AngularJS AngularJS-Questions Similar Reads What is the difference between '@' and '=' in directive scope in AngularJS ? AngularJS is a popular JavaScript framework, that provides powerful features for building dynamic web applications. When creating custom directives in AngularJS, you may come across the need to define a scope for your directive. The two most common methods to do this are by using the @ and = symbols 4 min read What is the Difference Between factory and service in AngularJS ? AngularJS is a JavaScript-based framework. It can be used by adding it to an HTML page using a <script> tag. AngularJS helps in extending the HTML attributes with the help of directives and binding of data to the HTML with expressions. In this article, we will explore the differences between t 4 min read What is the Difference Between required and ng-required in AngularJS ? In web application development, AngularJS is one of the most favorite dynamic JavaScript frameworks that has HTML through script tags, enabling us to augment the HTML attributes using the directives and facilitating the data binding through the expressions.In AngularJS, we can use certain Directives 3 min read What is the difference between ng-app and data-ng-app in AngularJS ? In web application development, AngularJS is one of the most favorite dynamic JavaScript frameworks that has HTML through script tags, enabling us to augment the HTML attributes using the directives and facilitating the data binding through the expressions.In this article, we will see the concepts o 5 min read What is the Difference Between Promises and Observables in Angular ? Angular is a TypeScript-based Single-Page Application framework used to create dynamic and responsive web applications. It is one of the most popular and robust frameworks. One of its key features is to handle Asynchronous Operations effectively. In Asynchronous, code is not executed sequentially ra 5 min read What is the difference between $watch and $observe in AngularJS ? AngularJS provides different methods to observe/watch the changes in its elements and variables. The $observe and $watch are two different methods that serve this purpose. $observe is a method that is responsible to observe/watch the changes in the DOM attribute. We use $observe when we want to obse 3 min read What is the Difference Between $evalAsync and $timeout in AngularJS? AngularJS is a JavaScript framework, which may be utilized by including it in an HTML web page the usage of a <script> tag. AngularJS enables in extension the HTML attributes with the assistance of directives and binding of data to the HTML with expressions. It provides various tools for handl 5 min read What Is Difference Between Style And StyleUrl In Angular? When you create a component in Angular, you sometimes want to style it to look good and match your application's design. Angular provides two ways to add styles to a component: style and styleUrls. They might look similar but they have different purposes. We know that the decorator functions of @Com 5 min read What is the Difference Between $routeProvider and $stateProvider in AngularJS ? In AngularJS, as we create Single-Page Applications, we need to implement the routing of components to view those images without having full page reloads. This can be achieved with the most popular routing methods, i.e., $routeProvider (ngRoute) and $stateProvider (ui-router).In this article, we wil 5 min read Difference between ng-container and ng-template in AngularJS Both ng-container and ng-template can be used to create responsive and dynamic components. Angular provides a set of structural directives that can be used with both ng-template and ng-container such as: ng-ifng-forng-switch. These structural directives are used to alter the structure of the DOM by 3 min read Like