E
E
Egor2015-02-16 12:20:53
JavaScript
Egor, 2015-02-16 12:20:53

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

2 answer(s)
D
Dmitry Dedukhin, 2015-02-16
@ByKraB

Are you hiding the form via ng-show/ng-hide?
Try it with ng-if.

N
Nikolay Talanov, 2015-02-16
@Ronnie_Gardocki

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 question

Ask a Question

731 491 924 answers to any question