0

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.

enter image description here

2 Answers 2

0

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>

Sign up to request clarification or add additional context in comments.

1 Comment

0

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.