HTML maxlength attribute not working on chrome and safari?

前端 未结 7 1673
借酒劲吻你
借酒劲吻你 2020-12-15 15:06


        
7条回答
  •  时光说笑
    2020-12-15 15:49

    The maxlength attribute does not apply to an input of type="number"

    From W3 HTML5 spec concerning type="number"

    The following content attributes must not be specified and do not apply to the element: accept, alt, checked, dirname, formaction, formenctype, formmethod, formnovalidate, formtarget, height, maxlength, multiple, pattern, size, src, and width.

    Source: http://dev.w3.org/html5/spec/Overview.html#number-state-type-number (under Bookkeeping details)

    In FF and IE, the input is falling back to be a text input and therefore, maxlength applies to the input. Once FF and IE implement type="number", they should also implement it in a way where maxlength does not apply.

提交回复
热议问题