html 中的输入字段可以有多少个字符?
html 输入字段中允许的“自然”字符数是多少?
非常感谢
由于评论而添加
我不需要通过post或get将其发送到服务器。 我将通过 JS 解析字符串。
因此,如果输入是无限的,就像@sAc所说,这给我带来了两个进一步的问题:
- JS可以最长的字符串是多少? 处理?
- 允许的最低金额是多少 共同输入的字符 浏览器?(这将是我的限制 比)
What is the "natural" number of allowed characters in an input field in html?
thanks a lot
addition due to the comments
i don't need to send it to the server via post or get.
i am going to parse the string via JS.
So if the input is unlimited like @sAc says brings me to two further questions:
- What is the longest String JS can
handle? - what is the lowest amount of allowed
characters for an input in common
browsers?(which would be my limit
than)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我的 32 位 Win 7 机器上的 Firefox 3.6.6 在 1,000,000 个字符后变得缓慢,在 4,000,000 个字符后完全冻结。
Chrome 在 8,000,000 后崩溃。
IE8 在 8,000,000 之后崩溃。
Safari 在 2,000,000 后崩溃。
在我的测试中,Chrome/IE8/Safari 不会像 Firefox 那样随着尺寸的增大而变慢。
Firefox 3.6.6 on my 32 bit Win 7 machine becomes slow after 1,000,000 characters and totally freezes after 4,000,000.
Chrome crashes somewhere after 8,000,000.
IE8 crashes somewhere after 8,000,000.
Safari crashes somewhere after 2,000,000.
In my testing Chrome/IE8/Safari don't slow down as the size goes up the way Firefox does.
来源:http://www.w3.org/TR/html401 /interact/forms.html#adef-maxlength
Source: http://www.w3.org/TR/html401/interact/forms.html#adef-maxlength
我不认为有限制,除非代码有什么东西阻止它(大小参数)或者服务器不能接受更多的字符(要么是很多字符,要么是服务器坏了)。
我相信,根据服务器的不同,还有 32 位等限制。
I wouldn't think there is a limit, unless the code has something stopping it (size parameter) or the server can't take any more characters (either a LOT of characters or a bad server).
There is also the 32bit etc. limits depending on the server, I believe.
我认为这取决于您发送表格的方法。如果您通过 GET 方法发送表单,则整个查询只有 255 个字符(如果我错了,请纠正我)。 POST 方法允许更多...
所以最终您可以在文本字段中写入数百万个字符,问题是,是否所有字符都发送到服务器。
然而,在 HTML 中,您可以指定允许的字符数。看一下这段代码:
标签的
maxlength
属性阻止用户输入超过 255 个字符。I think that depends on the method you are sending the form with. If you send the form via GET-method it's only 255 chars for the whole query (correct me if I am wrong). The POST-method allows much more...
So in the end you can write millions of chars in a text-field, the question is, if all chars are sent to the server.
In HTML however you've got the possibility to specify how many characters you want to allow. Look at this snippet:
The
maxlength
-attribute of the tag, prevents the user from being able to type in more than 255 chars.在文本区域中,您可以输入无限量的文本。
好的,实际上您不应该输入兆字节的文本,否则您将遇到服务器限制。
当您使用 POST 方法将表单发送到服务器(这是通常的方式)时,那么您至少可以发送兆字节。当您使用 GET 方法时,整个表单通过查询字符串传输,并且限制为数千个字符(确切的值取决于服务器和浏览器)。
In a textarea you can enter an unlimited amount of text.
OK, in practice you shouldn't enter megabytes of text or you will run into server limits.
When you the POST method to send the form to the server (which is the usual way), then you can send at least megabytes. When you use the GET method, the whole form is transferred through the querystring and there the limits are in the thousands of characters (the exact value depends on the server and the browser).
可见字符的数量取决于
input
元素的大小,还取决于该元素的样式:放置在浅容器中的宽框(例如,div
> 或form
)将不会显示字段中的所有字符。请参阅W3Schools 关于 INPUT 的说明,注意
大小
和maxlength
属性。maxlength
指定“文本”或“密码”类型的输入字段的最大长度(以字符为单位),size
指定输入字段的宽度。The number of visible characters is dependent on the size of the
input
element, but also on the style of that element: a wide box put in a shallow container (e.g., adiv
orform
) will not show all the characters in the field.See W3Schools explanation on INPUT, paying attention to
size
andmaxlength
attributes.maxlength
specifies the maximum length (in characters) of an input field for "text" or "password" types,size
specifies the width of an input field.