[whatwg] Can the maximum allowed value length be changed to restrict the number of characters?

Charles McCathie Nevile chaals at yandex-team.ru
Thu Aug 22 06:01:13 PDT 2013


On Tue, 20 Aug 2013 19:33:12 +0500, Boris Zbarsky <bzbarsky at mit.edu> wrote:

> On 8/19/13 7:40 PM, Ryosuke Niwa wrote:
>> Also,  
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-maxlength-attribute  
>> says "if the input element has a maximum allowed value length, then the  
>> code-unit length of the value of the element's value attribute must be  
>> equal to or less than the element's maximum allowed value length."
>>
>> This doesn't seem to match the behaviors of existing Web browsers
>
> The spec bit you quote above is an _authoring_ conformance requirement.  
>   That is <input maxlength="2" value="abc"> is not valid HTML and a  
> validator would flag it as invalid.  What UAs do with this markup, on  
> the other hand, is defined by the UA conformance requirements, and what  
> they do is allow a value longer than maxlength if it's specified.
>
>> or  
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#maximum-allowed-value-length
>
> These are the UA conformance requirements in question.
>
>> The paragraph should be revised to mention and only mention that the  
>> maxlength attribute affects the validation and the user agents may  
>> prevent the user from typing more characters than the specified value.
>
> The basic question is whether a validator should flag <input  
> maxlength="2" value="abc"> as a conformance error or not.  It seems to  
> me like it should.

Why? It seems that it generally works in browsers, and has for a long time.

On the other hand the use cases I can think of have mostly been taken over  
by placeholder, and pattern with good labelling, and so on.

cheers

-- 
Charles McCathie Nevile - Consultant (web standards) CTO Office, Yandex
       chaals at yandex-team.ru         Find more at http://yandex.com



More information about the whatwg mailing list