I have a basic input tag with no maxlength attribute defined:<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:
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 ?
答案 0 :(得分:0)
I don't know for sure, but I believe that if no maxlength is set on the input, the default is actually unlimited. 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.
References: What is the default maximum length of html input \ text area?
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.