1

<input type="hidden" value="Is there any limit that how many Hidden Fields ? "/>

Is there any limit for the how many Hidden Fields can be used in the HTML Form? If Yes, can you please elaborate the reason..?

Thanks..!

user2324085
  • 63
  • 1
  • 3
  • 11
  • Not related to being *hidden*, but [GET requests are limited in length](http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request), hence the number of parameters in GET requests is limited as well. – Arjan Oct 28 '13 at 08:36

5 Answers5

4

There is "NO" limit over how many hidden fields are there in a form..!

But, when you are trying to POST the value of all the hidden fields and normal should not more than post_max_size which is defined in php.ini

Mohan Raj
  • 447
  • 1
  • 5
  • 18
2

No. As long as each field has a unique name you are fine using as many as you would like:

<input type="hidden" name="must-be-unique" value="Some value"/>

EDIT: There is an exception to the unique name rule. In the case of radio buttons or anything where you'd like the data to be passed as an array, you may use the same name for multiple inputs.

Liftoff
  • 24,717
  • 13
  • 66
  • 119
  • @ComFreek It is better practice to make them unique, however. – Liftoff Oct 28 '13 at 08:28
  • @David What about arrays (`test[]`)? Radio groups must also have the same name in their group. – ComFreek Oct 28 '13 at 08:30
  • @user2324085 The number of fields *shouldn't* affect the form's "performance" per se. In theory, you can use as many as you want without it causing any problems, but as other answers have suggested, you may need to consider request size limits if you intend to use `GET` requests. – Liftoff Oct 28 '13 at 08:30
  • @ComFreek That is true; I'll give you that. Let me update my answer. – Liftoff Oct 28 '13 at 08:31
0

Actually there are some PHP parameters that control/effect the processing of inputs $_POST and $_GET data.

These are

max_input_vars = ??   // default is 1000, the number of fields php will process
max_input_time = ??   // maximum time in seconds a script is allowed to parse input data, like POST and GET
post_max_size = ??    // Sets max size of post data allowed.

These are not specifically related to "hidden" fields but to the total number of fields or size of the buffer. If your hidden fields are the last fields defined on your form and the number of fields or size of POST buffer is to large, php just stops processing when the limit it reached. However you should see at least a warning in your php error log to say something like this has happened.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
0

In case you are generating hidden fields dynamically using JS for example you can limit, else you cannot control and having many fields may make your page performance bad You can make periodical check using JS to count hidden fields and you may delete last added ones based on your implementation Also you can have N elements with same name in HTML but in PHP I don't know if you will face limitation or not

function checkDOMChange()
{
    // check for any new element being inserted here,
    // or a particular node being modified

    // call the function again after 100 milliseconds
    setTimeout( checkDOMChange, 100 );
}
-1

Some browsers (ex: Netscape, IE) have a limit for hidden field content size, but not for field count. In those situations the quick walkaround is to divide content into multiple hidden fields.

Kuzgun
  • 4,649
  • 4
  • 34
  • 48