[whatwg] :valid / :invalid only works in forms
arv at chromium.org
Fri Feb 12 09:56:03 PST 2010
At the moment an input element needs to part of a form and have a name
attribute for the CSS pseudo classes :valid and :invalid to be
applied.  These limitations forces people to make their DOM more
complicated just to be able to use these pseudo classes. It might have
not available but in many modern web apps there is no need for forms
nor name attributes.
Can we please remove these limitations?
 https://bugs.webkit.org/show_bug.cgi?id=34733#c7 (included below
> Constraint validation: If an element has no form owner, it is barred
> from constraint validation.
> Constraint validation: If an element does not have a name attribute
> specified, or its name attribute's value is the empty string, then
> it is barred from constraint validation.
> The :valid pseudo-class must match all elements that are candidates for
> constraint validation and that satisfy their constraints.
> The :invalid pseudo-class must match all elements that are candidates
> for constraint validation but that do not satisfy their constraints.
> A listed form-associated element is a candidate for constraint
> validation except when a condition has barred the element from
> constraint validation.
More information about the whatwg