[whatwg] Incomplete user-input in some input types
tkent at chromium.org
Wed Sep 12 23:18:48 PDT 2012
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.
This behavior should be applied to the following types:
number, color, date, datetime, datettime-local, month, time, and week
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.
Software Engineer, Google
More information about the whatwg