html 表单中输入标签的最大数量是多少?
我在 w3c html 严格规范中找不到任何信息 http://www.w3.org/TR/html4/sgml/dtd.html
i can't find any information inside the w3c html strict spec
http://www.w3.org/TR/html4/sgml/dtd.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
PHP 用户:
如果您使用 php 处理表单,请注意 php 在 php ini 文件中具有 max_input_vars 设置。我相信默认值是 1000。
我在构建 cakephp 应用程序时遇到了这个问题。要查看这是否影响您的帖子,请计算您在表单中放入的数据行数,然后计算实际发回的行数。
因此,本质上您的表单将受到您拥有的输入变量数量的限制。
这并不是对OP的直接回答,但我认为这对于任何寻求输入字段限制的人都会有帮助。
PHP USERS:
If you are using php to process your form take note that php has a max_input_vars setting in the php ini file. I believe the default is 1000.
I ran into this while building a cakephp app. To see if this is affecting your post, count how many rows of data you are putting into the form and then count how many rows are actually posted back.
So essentially your form would be limited by the number of input vars you have.
This isn't really an direct answer to the OP but I think it would be helpful for anyone searching for a limit on input fields.
据我所知,HTML 文档中的表单元素(
或其他)的数量没有上限。
但是,如果页面上有大量表单元素,则最终可能会出现 POST 请求太大而无法由 Web 服务器处理的情况(POST 请求的最大大小取决于服务器配置)。
To my knowledge, there is no upper limit to the number of form elements (
<input>
or otherwise) in an HTML document.However, if you have a huge number of form elements on your page, you might end up with a POST request that is too large to be processed by the web server (the maximum size of POST requests depends on the server configuration).
我认为规范给出的表单中没有最大数量的
input
元素(如果这就是您所要求的)。如果您有很多输入并希望确保该表单有效,则必须在您支持的客户上进行尝试。当然,如果可能的话,重新设计表单会更好。I don’t think there’s a maximum number of
input
elements in a form given by the spec, if that’s what you are asking. If you have many inputs and want to make sure the form works, you’ll have to try on the clients you support. And of course, it would be much better to redesign the form, if that’s possible.我认为标准中未输入字段的数量没有限制。
您需要考虑两个实际限制:
如果页面上有太多输入字段,某些浏览器就会开始工作。我还没有在最近的版本中尝试过这一点,但我记得几年前对此进行过测试,然后我发现当字段数量接近一百时,Internet Explorer 的表现很糟糕。
页面上太多的输入字段会给用户带来不方便,甚至可能有点可怕。将输入拆分到多个页面上,或者显示占位符并仅在实际使用的地方动态添加输入字段。
I don't think that there is a limitation on the number of unput fields in the standards.
There are two practical limitations that you need to consider:
Some browsers start to act up if there are too many input fields on a page. I haven't tried this with recent versions, but I remember testing this a few years back, and then I found that Internet Explorer behaved badly when the number of fields was closing to a hundred.
Too many input fields on a page is just inconvenient, and perhaps a bit scary, to the user. Split the input on several pages, or show placeholders and add input fields dynamically only where they are actually used.
从技术上讲,页面上可以放置的输入字段的最大数量没有限制。实际上,对于用户来说,如果网页具有大量的输入字段,则用户使用/查看所有的输入字段会有些不方便。
Technically, there is no maximum number of input fields that can be put on a page. Practically, for a user, it is a bit inconvenient for a user to use/see all of the input fields if a web page has a large number of input fields.
我在旧应用程序中遇到了类似的问题。
我认为这是对 max_input_vars 的 HTML 输入元素或 PHP ini 配置数量的限制。
但经过更多调查后,发现是安装在我的生产计算机上的 Suhosin,它以低得多的限制覆盖了 PHP.ini 配置值。
suhosin.post.max_vars = 400
I was encountering a similar problem in an old application.
I thought it was a limit to the number of HTML input elements or PHP ini configuration for max_input_vars.
But after more investigation, it turns out it was Suhosin that was installed on my production machine which over wrote the PHP.ini config value with a much lower limit.
suhosin.post.max_vars = 400
请注意,我们无法在运行时使用函数 ini_set 设置此 max_input_vars 指令。我们可以直接在php.ini文件中更改它。
不要忘记重新启动网络服务器。有时我们需要重启服务器才能生效。
Please note that we cannot set this max_input_vars directive in run-time with function ini_set. We can change it directly in php.ini file.
Don't forget to restart web server. Sometimes we need to reboot the server to take effect.
我刚刚也遇到了这个问题。我自动创建了几百行输入,它们会发送 1/2 的变量。我使用 print_r Vars_Dump 检查,如果我只创建 20 行,那么一切都没有问题。可以发送的变量数量是有限制的。 最大输入变量
默认限制为 1000。我联系了我的托管提供商,他们相应地更改了 php.ini。
I just also ran into this problem. I automatically created several hundred rows of inputs and they would old send 1/2 of the variables. I checked by using print_r Vars_Dump, If I just created 20 rows, it all went without problems. There is a limit of how many variables can be sent. max_input_vars
is limited to 1000 on default. I contacted my hosting provider and they changed the php.ini accordingly.