Why is the default max length for an input 524288?

℡╲_俬逩灬. 提交于 2019-12-17 16:27:56

问题


The default maximum length for a HTML input (<input type="text">) is 524288 characters. That seems like a very peculiar number, why was it chosen?


回答1:


According to the w3c the maximum value is unlimited:

maxlength = number [CN]

When the type attribute has the value "text" or "password", this attribute specifies the maximum number of characters the user may enter. This number may exceed the specified size, in which case the user agent should offer a scrolling mechanism. The default value for this attribute is an unlimited number.

Despite that, I have noticed that in Chrome indeed defaults the maxlength to 524288, which seems a 'bug 'to me, or at least a deliberate choice to cap the input to 512KB (thanks to Benjamin Udink ten Cate for pointing that out).



来源:https://stackoverflow.com/questions/26469152/why-is-the-default-max-length-for-an-input-524288

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!