Re: [whatwg] Incomplete user-input in some input types

> A. In such case, make input.validity.typeMismatch true, or
> B. Introduce new IDL attribute to ValidityState.
> input.validity.invalidUserInput?

C. Just validity.valid becomes false.
    An implementation would have an internal flag like invalidUserInput, but
it won't be exposed via IDL.

C would have less impact to the standard.  If no one has concern about this
idea, I'd like to implement C in WebKit.


On Thu, Sep 13, 2012 at 3:18 PM, TAMURA, Kent <tkent@chromium.org> wrote:
> Proposal:

> Making an input element invalid state if the input has an invalid string
> specified by a user with browser UI. "An invalid string" means a string
> which doesn't match to a required format defined by a type.

>     e.g. If a user typed "-" to input[type=number], input.validity.valid
> would
> be false and form submission would be prevented.

> A. In such case, make input.validity.typeMismatch true, or
> B. Introduce new IDL attribute to ValidityState.
> input.validity.invalidUserInput?

> This behavior should be applied to the following types:
>     number, color, date, datetime, datettime-local, month, time, and week


> Background:
>     If an input type is implemented as a text field, it is very hard for UA
> to
> reject invalid strings for the type. For example, "-" is not a valid
> floating-point number, but UA can't prevent users from typing "-".  So the
> field can contain invalid strings though its value IDL attribute is empty.
> If a user tries to submit the form in such situation, the field is valid
> unless the required attribute is specified.
>     WebKit clears the invalid string when the field loses focus or the form
> is
> submitted.  A sanitized value (empty string) is submitted.
>     Opera doesn't clear the invalid string. It silently submits a sanitized
> value (empty string).
>     IE10 has a behavior similar to WebKit.  However if a user type "-1abc",
> "-1abc" is submitted.

> I don't like clearing user input.  It's not a good user experience.  Users
> don't expect their input strings are cleared by UA.
> Also, I don't like submitting empty value silently. Users expect their
> input
> strings are submitted.
> I think the best UI is to notify users about a field has an invalid
> string,
> and give a chance to correct it.  Applying the standard form validation
> mechanism must be reasonable.



> --
> TAMURA Kent
> Software Engineer, Google





-- 
TAMURA Kent
Software Engineer, Google

Received on Thursday, 8 November 2012 07:03:33 UTC