[whatwg] :valid / :invalid only works in forms

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. [1] These limitations forces people to make their DOM more
complicated just to be able to use these pseudo classes. It might have
made sense to have these limitations in a world where JavaScript was
not available but in many modern web apps there is no need for forms
nor name attributes.

Can we please remove these limitations?

Erik Arvidsson


[1] https://bugs.webkit.org/show_bug.cgi?id=34733#c7 (included below
for completeness)

http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#association-of-controls-and-forms
> Constraint validation: If an element has no form owner, it is barred
> from constraint validation.

http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#naming-form-controls
> 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.

http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#pseudo-classes
> :valid
> The :valid pseudo-class must match all elements that are candidates for
> constraint validation and that satisfy their constraints.
>
> :invalid
> The :invalid pseudo-class must match all elements that are candidates
> for constraint validation but that do not satisfy their constraints.

http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#candidate-for-constraint-validation
> A listed form-associated element is a candidate for constraint
> validation except when a condition has barred the element from
> constraint validation.

Received on Friday, 12 February 2010 09:56:03 UTC