Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On Wed, 11 Jan 2012, Mounir Lamouri wrote: On 01/11/2012 01:05 AM, Ian Hickson wrote: On Tue, 14 Jun 2011, Rafa�~B Mi�~Becki wrote: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? Example: p id=errYou've to fill all required fields/p form:invalid #err { display: block; } On Wed, 15 Jun 2011, Boris Zbarsky wrote: Yep. I think we should do it. I've added this to the spec. Wouldn't be interesting to have the same thing for fieldset? Are there sites that indicate validity of sections of the form in this way? -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On Tue, 14 Jun 2011, Rafa�~B Mi�~Becki wrote: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? Example: p id=errYou've to fill all required fields/p form:invalid #err { display: block; } On Wed, 15 Jun 2011, Boris Zbarsky wrote: Yep. I think we should do it. I've added this to the spec. On Wed, 15 Jun 2011, Mounir Lamouri wrote: By the way, for what it worth, I've mention that in this mailing list and got no feedback. I'm happy to see someone else asking for it and I might implement that in Gecko. My apologies. Do you have a link to your earlier feedback on this so that I can audit why it never received a response? -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On 01/11/2012 01:05 AM, Ian Hickson wrote: On Tue, 14 Jun 2011, Rafa�~B Mi�~Becki wrote: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? Example: p id=errYou've to fill all required fields/p form:invalid #err { display: block; } On Wed, 15 Jun 2011, Boris Zbarsky wrote: Yep. I think we should do it. I've added this to the spec. Wouldn't be interesting to have the same thing for fieldset? -- Mounir
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
2011/6/14 Rafał Miłecki zaj...@gmail.com: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? Example: p id=errYou've to fill all required fields/p form:invalid #err { display: block; } This would be more a CSS Selectors concern, and there are already some ideas at [1] that would address this. Regards, Eduard Pascual [1]: http://wiki.csswg.org/spec/selectors4
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On 6/15/11 4:31 AM, Eduard Pascual wrote: 2011/6/14 Rafał Miłeckizaj...@gmail.com: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? This would be more a CSS Selectors concern No, it wouldn't. The point here is to style based on a _form_ that is invalid. Whether a form is valid or not is up to the language defining forms, that being HTML. and there are already some ideas at [1] that would address this. ... [1]: http://wiki.csswg.org/spec/selectors4 None of the ideas there address this use case. Nor can they, being pure CSS proposals. -Boris
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On 06/15/2011 07:00 PM, Boris Zbarsky wrote: On 6/15/11 4:31 AM, Eduard Pascual wrote: 2011/6/14 Rafał Miłeckizaj...@gmail.com: We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? This would be more a CSS Selectors concern No, it wouldn't. The point here is to style based on a _form_ that is invalid. Whether a form is valid or not is up to the language defining forms, that being HTML. Isn't that somewhat related to CSS UI too? By the way, for what it worth, I've mention that in this mailing list and got no feedback. I'm happy to see someone else asking for it and I might implement that in Gecko. -- Mounir
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On 6/15/11 1:08 PM, Mounir Lamouri wrote: Isn't that somewhat related to CSS UI too? Last I checked, CSS UI defined that the pseudo-classes exist, but left when they apply up to the language defining the elements. By the way, for what it worth, I've mention that in this mailing list and got no feedback. I'm happy to see someone else asking for it and I might implement that in Gecko. Yep. I think we should do it. -Boris
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
2011/6/15 Boris Zbarsky bzbar...@mit.edu: No, it wouldn't. The point here is to style based on a _form_ that is invalid. Whether a form is valid or not is up to the language defining forms, that being HTML. Sorry, I assumed the simple definition that a form is invalid if it contains invalid input elements, and there are proposals on the wiki to deal with selecting an element based on its children. Of course, something like form:invalid { ... } would be ideal, but a syntax like $form :invalid { ... } wouldn't be too bad. I missed the possibility of a validation script (onsubmit event handler) making more complex checks (like if first field is X, then the second field can be anything but Y). However, there is no clean way to deal with those cases short of adding onchange handlers on all inputs: - If a browser attempts to run the onsubmit handler upon each change, to update the style of the form as soon as it becomes (in)valid, then there is a risk of the javascript having some side-effect that is not intended to happen on each change. - If a browser waits for a submit attempt, this can easily become confusing to users (the change in style should be triggered by the change that actually made the form invalid). That would partially depend on the actual style applied; but it could be easily implemented by the document author with a single javascript line (adding a class or some other attribute to the form), so the feature would be a sort of glorified syntax sugar. Maybe a sort of compromise would be implemented: checking for invalid individual elements and, if the onsubmit handler is known to not trigger side-effects, check it as well. But this sounds more like a hack. Is there something I am missing? Regards, Eduard Pascual
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
On 6/15/11 3:12 PM, Eduard Pascual wrote: 2011/6/15 Boris Zbarskybzbar...@mit.edu: No, it wouldn't. The point here is to style based on a _form_ that is invalid. Whether a form is valid or not is up to the language defining forms, that being HTML. Sorry, I assumed the simple definition that a form is invalid if it contains invalid input elements A form need not contain its controls. Consider this HTML document: !DOCTYPE html form id=myform action=something input type=submit /form input type=number value=abracadabra form=myform How would you select the form based on the valid/invalid state of the number input? and there are proposals on the wiki to deal with selecting an element based on its children. Not good enough; see above. -Boris
Re: [whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
2011/6/15 Boris Zbarsky bzbar...@mit.edu: A form need not contain its controls. Consider this HTML document: !DOCTYPE html form id=myform action=something input type=submit /form input type=number value=abracadabra form=myform So, indeed, I was missing something. Disregard my previous posts then. Regards, Eduard Pascual
[whatwg] Idea: pseudo-classes :valid and :invalid for whole form?
We already have required attribute and :valid plus :invalid classes, which are nice. However some may want to display additional warning when form wasn't filled correctly. Just some single warning, not specific field-related. Could you consider adding form element class for such a purpose? Example: p id=errYou've to fill all required fields/p form:invalid #err { display: block; } -- Rafał