[html5] Is html5.validator.nu wrong about <input>

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Tue Apr 10 03:21:34 PDT 2012


2012-04-10 13:02, Prof. T.D. Wilson wrote:

> *Error*: Attribute |maxlength| not allowed on element |input|
> <http://www.whatwg.org/specs/web-apps/current-work/#the-input-element> at this
> point.
>
>  From line 342, column 2; to line 342, column 206
>
> |ht:32;">↩ *<input type="hidden" name="q" maxlength="255" size="31"
> value=""health information" (&quo…ormation seeking" or
> "information searching" or "information use")
> Canada">*<br />|

The key issue here is that the field is hidden, type="hidden".

> |However, all the information I can find about both 'maxlength' and
> 'size' (which is also rejected in the same way) tells me that both are
> permitted in html5. Is the validator wrong on this?|

The validator correctly reflects the HTML5 drafts. Very few attributes 
are allowed for <input type="hidden">:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#the-input-element

The reason is that the disallowed attributes relate to visual 
presentation or functionality related to user interaction, and hidden 
fields are not expected to be displayed and not expected to interact 
with the user.

If you use an <input> element in different states, dynamically 
(client-side) switching e.g. from type="hidden" to type="text", then you 
should write the static markup according to the initial state and add 
attributes dynamically if needed.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/



More information about the Help mailing list