[whatwg] Form element invalid message

Aryeh Gregor Simetrical+w3c at gmail.com
Wed Sep 22 15:05:04 PDT 2010


On Wed, Sep 22, 2010 at 5:51 PM, Aryeh Gregor <Simetrical+w3c at gmail.com> wrote:
> Note that Firefox is buggy here
> and treats setCustomValidity('') as setting the error message to ''
> instead of removing it, as the spec says, but when that's fixed it
> will work.

I take it back.  Firefox and Opera do give different results, but the
bug in Firefox (if it is one) is subtler.  This works as I expect in
both:

data:text/html,<!doctype html>
<form>
<input name=x required oninvalid="
    this.setCustomValidity('');
    if (!this.validity.valid) {
        this.setCustomValidity('abcd');
    }
" onfocus="this.setCustomValidity('')">
<input type=submit>
</form>

My previous version would have looked odd in Firefox regardless, since
it gives a red halo around invalid elements, and it would remain
invalid even after the user entered stuff.  This one should work
pretty well.  And yes, you could always conceive of simple declarative
APIs that would do this stuff, but you just can't add those for every
single feature someone wants.



More information about the whatwg mailing list