最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Limit for Hidden Fields in HTML Form - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question asked Oct 28, 2013 at 8:25 user2324085user2324085 631 gold badge3 silver badges12 bronze badges 1
  • Not related to being hidden, but GET requests are limited in length, hence the number of parameters in GET requests is limited as well. – Arjan Commented Oct 28, 2013 at 8:36
Add a ment  | 

5 Answers 5

Reset to default 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

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.

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.

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 );
}

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.

发布评论

评论列表(0)

  1. 暂无评论