- From: TAMURA, Kent <tkent@chromium.org>
- Date: Thu, 13 Sep 2012 15:18:48 +0900
- To: whatwg <whatwg@lists.whatwg.org>
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
Received on Thursday, 13 September 2012 06:19:36 UTC