Re: :invalid

On Sep 23, 2010, at 10:58 PM, Jonas Sicking wrote:

> 1. Change the way :invalid works such that it is defined to only match
> when we want to *render* invalid UI, not anytime a form control
> doesn't match its constraints.
> 2. Introduce a new pseudo class :invalid-ui which only matches when we
> want to render invalid UI. (For now we'd -moz- prefix it of course)
> 
> Both these solutions are flexible in that it allows us to adjust the
> rules for when we want to render UI without having to introduce
> additional complexity. And both these solutions allow authors to
> easily override the default style and introduce their own.
> 
> The downside with solution 1 is that it affects non-styling uses of
> selectors. Such as the DOM functions querySelector/querySelectorAll.

Can't you just get rid of that downside by letting those selectors automatically match as though they were one of the times when you want to render invalid UI? That is, they would return a list of everything invalid or not yet valid, regardless of whether it has been rendered that way yet?

I'm just imagining the use cases, and thinking that it would be for a button that checks the validity without actually submitting, or perhaps something that writes out a list of everything that is not yet valid (or that is). In those cases you'd want a list of every match, not just the ones those where the style has actually been rendered to indicate it.

In other words, "not yet valid" does match, but you just aren't required to render the pseudo-class until you want to, such as when tabbing out of the field (unlike something like :hover, where you render as soon as it matches).

Received on Friday, 24 September 2010 15:09:58 UTC