Answer the question
In order to leave comments, you need to log in
Angularjs. How to remove validation (ng-dirty, ng-invalid etc.) classes after previous validation without bypassing all inputs?
Greetings.
I have a form that appears when a button is clicked. The situation is as follows:
1. The user opened the form, entered some invalid data. The inputs received the corresponding classes 'ng-diry, ng-required-invalid', etc.
2. The user did not submit the form, but simply closed it.
3. The user opened the form again, but the form itself and the inputs are 'ng-invalid, ng-dirty, etc'.
Is it possible to quickly reset validation classes without looping through every input in the form?
Answer the question
In order to leave comments, you need to log in
Are you hiding the form via ng-show/ng-hide?
Try it with ng-if.
The $setPristine() method applied to the form should remove all ng-dirty and other stuff. It essentially "cleans" the form.
https://docs.angularjs.org/api/ng/type/form.FormCo...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question