Re: :invalid

2010-09-25 18:59 EEST: Brad Kemper:
> If we had :dirty, wouldn't that take care of all needs (assuming that
> loosing focus makes a field dirty)? Then you could just have these:
> 
> input:dirty:valid {/* smiley face, green, etc. */} 
> input:dirty:invalid {/* caution sign, red, etc.  */}

If I've understood correctly, the need for this selector is more along
the lines "this elements needs attention" instead of "this element is
invalid" (the latter case being handled with currently specified
:invalid selector).

I'll rephrase the objective as I've understood it:

(1) A newly rendered form with e.g. empty required fields should be
rendered without error markers (I personally don't agree with this - if
a field requires some input, I'll rather have a clear marker immediately).

(2) A form input that has been interacted with and is still invalid
needs more attention from the user (however, in case of e.g. text input,
if the focus is in the text input, demand more attention only at onblur
of text input)

(3) A form input that has not been interacted with and is invalid when
user is trying to submit the form requires more attention from the user.
(In addition, the form submitting is cancelled.)


As I see it, there should be a new pseudo class for any element that
demands attention. Logically this could be a paragraph with an important
notice, a site navigation menu with a newly added entry or whatever. As
such, I don't think this should be limited to form inputs only. (Note
that this similar to "this window demands attention" or "this window has
an urgent message" properties of windows in window managers of operating
systems.)

An actual UA implementation could specify invalid field rendering with
selector

:invalid:needs-attention { /* styles for invalid input element */ }

and the :needs-attention could be raised with UA specific rules (I'd
leave this open for UAs to compete on) in addition to explicitly set
needs-attention "flags" raised by content author specified scripts.

-- 
Mikko

Received on Monday, 27 September 2010 08:30:38 UTC