I am trying to validate form but it shows red fields when first time the form load I do not want to show any validation for first time. How to achieve it.
2 Answers
share code first (or make plunker). Did you use HTML no validate in the form ?
If not then use it like <form name="createForm" novalidate>
1 Comment
Malik Kashmiri
stackoverflow.com/questions/38695778/… here is the code
I think it is pretty hard to stop angular for putting .ng-invalid class.
What I can do is, I will use .ng-pristine class to manage it manually,
NOTE: I'm just giving you a way.
.ng-pristine{
border:2px solid gray; /* add your css rules as required */
}
1 Comment
micronyks
This is the correct way: official docs says:
This user experience is the developer's choice. Some folks want to see the message at all times. If we ignore the pristine state, we would hide the message only when the value is valid. If we arrive in this component with a new (blank) hero or an invalid hero, we'll see the error message immediately, before we've done anything.Some folks find that behavior disconcerting. They only want to see the message when the user makes an invalid change. Hiding the message while the control is "pristine" achieves that goal.