Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the default max length for an input 524288?

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?

like image 576
Mike Avatar asked Oct 20 '14 15:10

Mike


People also ask

What is the purpose of limit length of input?

The maxlength attribute allows you to specify a maximum number for characters for a text-based input field. This can help usability, such as when you need to limit the length of usernames or other types of input date.

How do you set the maximum length of an input tag?

The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> . This must be an integer value 0 or higher. If no maxlength is specified, or an invalid value is specified, the input or textarea has no maximum length.

How do I limit the number of characters in an input field?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.

How do you set the length of an input number in HTML?

Input value length You can specify a minimum length (in characters) for the entered value using the minlength attribute; similarly, use maxlength to set the maximum length of the entered value, in characters. The example below requires that the entered value be 4–8 characters in length.


1 Answers

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).

like image 92
Patrick Hofman Avatar answered Oct 16 '22 17:10

Patrick Hofman