Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a max size to the length of a hidden input in html?

Tags:

html

input

in other words:

<input type="hidden" value="Can I put as much as I want in here, or is there a limit?" /> 

and if so, what is it?

like image 806
sprugman Avatar asked Nov 18 '09 00:11

sprugman


People also ask

How do you restrict input length in HTML?

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.

Which attribute can be used to specify a limit on the number of characters a user can enter into an input element?

The MAX attribute can be used to specify an upper limit to the number of characters that can be entered into a text field, e.g. MAX=72 .


2 Answers

It depends on the method you send the form with.

With GET, there is a commonly agreed on limit of about 1-2 kilobytes, depending on browser and server limitations.

With POST, there is no technical limit in the browser, but usually one on the server side - see e.g. Apache's LimitRequestBody, PHP's post_max_size and so on.

like image 167
Pekka Avatar answered Oct 14 '22 22:10

Pekka


Warning! I have experienced problems with <input type="text"> when text is longer than 65535 (max signed int size)

Pasting the text seems to cause some weird overflow of content. Spotted in webkit.

[edit]

The size of GET request is not exactly limited the way Pekka wrote. There is a limit of 2083 bytes for the whole GET query string address?params in Internet Explorer only In other browsers there is practically no limit, with FireFox sending GET queries of over 100KB for example. Obviously the server has to allow those.

It's not covered in documentation, so one has to test it to know the limits for other browsers. IE: http://support.microsoft.com/kb/208427

like image 41
naugtur Avatar answered Oct 14 '22 22:10

naugtur