I agree with Erik. It's useful if the pseudo classes work without a <form> element and name attribute. <input> element is often used without a <form> element in web applications.<div><br></div><div>A related topic:</div>
<div><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#definitions">http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#definitions</a></div>
<div><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#definitions"></a><div><div class="gmail_quote">> Note: An element can still suffer from these states even when the</div>
<div class="gmail_quote">> element is disabled; thus these states can be represented in the</div><div class="gmail_quote">> DOM even if validating the form during submission wouldn't indicate</div><div class="gmail_quote">
> a problem to the user.</div><div class="gmail_quote"><br></div><div class="gmail_quote">This paragraph mentions only "disabled". But it means ValidityState also works without a form element, without a name attribute, or with a readonly attribute, right?</div>
<div class="gmail_quote"><br></div>An element is a "candidate for constraint validation" if</div><div> 1. it is a validatable type,</div><div> e.g. true if <input type=number>, false if <input type=reset></div>
<div> 2. has no "disabled" attribute,</div><div> 3. has no "readonly" attribute,</div><div> 4. inside of a <form> element,</div><div> 5. has non-empty "name" attribute, and</div><div> 6. not inside of a <datalist> element.</div>
<div><br></div><div>I hope ValidityState and the pseudo classes ignores 2-6.</div><div><div class="gmail_quote"><br>On Sat, Feb 13, 2010 at 02:56, Erik Arvidsson <span dir="ltr"><<a href="mailto:arv@chromium.org">arv@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">At the moment an input element needs to part of a form and have a name<br>
attribute for the CSS pseudo classes :valid and :invalid to be<br>
applied. [1] These limitations forces people to make their DOM more<br>
complicated just to be able to use these pseudo classes. It might have<br>
made sense to have these limitations in a world where JavaScript was<br>
not available but in many modern web apps there is no need for forms<br>
nor name attributes.<br>
<br>
Can we please remove these limitations?<br>
<br>
Erik Arvidsson<br>
<br>
<br>
[1] <a href="https://bugs.webkit.org/show_bug.cgi?id=34733#c7" target="_blank">https://bugs.webkit.org/show_bug.cgi?id=34733#c7</a> (included below<br>
for completeness)<br>
<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#association-of-controls-and-forms" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#association-of-controls-and-forms</a><br>
> Constraint validation: If an element has no form owner, it is barred<br>
> from constraint validation.<br>
<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#naming-form-controls" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#naming-form-controls</a><br>
> Constraint validation: If an element does not have a name attribute<br>
> specified, or its name attribute's value is the empty string, then<br>
> it is barred from constraint validation.<br>
<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#pseudo-classes" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#pseudo-classes</a><br>
> :valid<br>
> The :valid pseudo-class must match all elements that are candidates for<br>
> constraint validation and that satisfy their constraints.<br>
><br>
> :invalid<br>
> The :invalid pseudo-class must match all elements that are candidates<br>
> for constraint validation but that do not satisfy their constraints.<br>
<br>
<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#candidate-for-constraint-validation" target="_blank">http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#candidate-for-constraint-validation</a><br>
> A listed form-associated element is a candidate for constraint<br>
> validation except when a condition has barred the element from<br>
> constraint validation.<br>
</blockquote></div><br><br clear="all"><br>-- <br>TAMURA Kent <br>Software Engineer, Google <br><br><br><br>
</div></div>