{"id":335874,"date":"2021-03-08T08:03:44","date_gmt":"2021-03-08T16:03:44","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=335874"},"modified":"2021-03-08T08:04:34","modified_gmt":"2021-03-08T16:04:34","slug":"form-validation-styling-on-input-focus","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/snippets\/css\/form-validation-styling-on-input-focus\/","title":{"rendered":"Form Validation Styling on Input Focus"},"content":{"rendered":"\n
\/* Only show invalid ring while not focused *\/\ninput:not(:focus):not(:placeholder-shown):invalid {\n  border-color: var(--color-invalid);\n}\ninput:not(:focus):not(:placeholder-shown):invalid ~ .error-message {\n  display: block;\t\n}\n\n\/* Only show valid ring while not focused and if a value is entered *\/\n\/* :empty won't work here as that targets elements that have no childeren. Therefore we abuse :placeholder-shown *\/\ninput:not(:focus):not(:placeholder-shown):valid {\n  border-color: var(--color-valid);\n}<\/code><\/pre>\n\n\n\n

Pulling this straight from the Weekly Platform News, where \u0160ime Vidas covers two long ongoing issues<\/a> with using :invalid<\/code> to style form input validation. Apparently, what happens is…<\/p>\n\n\n\n