Post

you can use CSS to detect not only when a form is :valid but also when it's been interacted with s/:valid/:user-valid 🤙 .group:has(:user-invalid) { --color: var(--invalid); } input:user-invalid + .error { display: block; }

Helge Ahrens@tylopilus.bsky.social

@jhey.dev I have read somewhere how to create custom validation messages of form fields without js. Do you have a reference at hand?

i'd go for it with styles in a progressively enhanced way the number of unsupported users is perhaps ~5% across "popular" browsers there but for those without support, are they going to miss/care if the input doesn't change color?

the error message part could be handled differently but you'll need JavaScript anyway in order to update any appropriate aria-* attributes on submit that said, i am still not 100% on this because with forms where we don't use client scripting, do we just not bother with dynamic messaging

0 reposts2 likes

No replies yet.