ngx-schema-form icon indicating copy to clipboard operation
ngx-schema-form copied to clipboard

Show red border only on invalid fields

Open rockstarjindal opened this issue 7 years ago • 5 comments

So the way validation currently works is that it sets 'has-success' 'has-errors' on parent and children both.

Assuming a parent div has multiple elements where one of them is invalid, all of the rest of the fields also go red because somehow browser is preferring has-error class (which is farther dom-wise) over has-success class.

Logically we should have has-success and has-error on parent elements to know the whole form status at a glance but that shouldn't change the css attribute of children elements.

E.g. Form with invalid date where all the fields are in red screen shot 2018-02-08 at 4 55 55 pm

After date correction all the fields go green screen shot 2018-02-08 at 4 56 27 pm

rockstarjindal avatar Feb 09 '18 01:02 rockstarjindal

+1

ebrehault avatar Feb 09 '18 07:02 ebrehault

This works for me:

.form-control.ng-untouched,
.form-control.ng-valid {
    border-color: #ccc !important;
}

Is this the "official way to go" at least at the moment?

WhileTrueEndWhile avatar Mar 09 '18 07:03 WhileTrueEndWhile

Simple solutions are good solutions :)

ebrehault avatar Mar 09 '18 07:03 ebrehault

// Working fine .form-control.ng-untouched, .form-control.ng-valid { border-color: #ccc !important; }

sacse2010 avatar Apr 02 '20 04:04 sacse2010

What if the response is coming back from the backend ? may be like this { name:["name fields exceeds its character limit"] ,......} How can we achieve the same in such case ? I am pretty beginner in this field so don't mind If I sound stupid.

rautNitesh avatar Nov 19 '20 03:11 rautNitesh