[英]Default value of maxLength input in different browsers
I have a basic input tag with no maxlength attribute defined: <input id="foo" type="text" />
我有一个没有定义maxlength属性的基本输入标记: <input id="foo" type="text" />
Trying to get the maxlength attribute in different browsers with the code document.getElementById("foo").maxLength
returns the following values: 尝试使用代码document.getElementById("foo").maxLength
获取不同浏览器中的maxlength属性document.getElementById("foo").maxLength
返回以下值:
console.log(document.getElementById("foo").maxLength);
<input id="foo" type="text"/>
Why is this happening if the default value of maxlenght is 524288 according to https://www.w3schools.com/tags/att_input_maxlength.asp ? 根据https://www.w3schools.com/tags/att_input_maxlength.asp,如果maxlenght的默认值为524288,为什么会发生这种情况?
I don't know for sure, but I believe that if no maxlength is set on the input, the default is actually unlimited. 我不确定,但我相信如果输入上没有设置maxlength ,默认实际上是无限制的。 This is then applied by the browser and is specific to the platform. 然后,这将由浏览器应用,并且特定于平台。 The W3schools link mentions 512KB as the maximum but that was presumably a value applied by specific browsers. W3schools链接提到512KB作为最大值,但这可能是特定浏览器应用的值。
References: What is the default maximum length of html input \\ text area? 参考: html输入\\文本区域的默认最大长度是多少?
Edit: just checked https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text and correctly there is no default maxlength, so Chrome and Edge are reporting that correctly. 编辑:刚刚检查了https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text,并且没有默认的maxlength,因此Chrome和Edge正确报告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.