我有以下 html5 输入元素:
<input type="number">
为什么这个输入允许在输入字段中输入字符“e”?无法输入其他字母字符(如预期的那样)
使用 chrome v. 44.0.2403.107
下面的例子来看看我的意思。
<input type="number">
最佳答案
因为这正是 the spec说它应该工作。输入的数字可以接受floating-point numbers ,包括负号和 e
或 E
字符(其中指数是 e
或 E
之后的数字):
A floating-point number consists of the following parts, in exactly the following order:
- Optionally, the first character may be a "
-
" character.- One or more characters in the range "
0—9
".- Optionally, the following parts, in exactly the following order:
- a "
.
" character- one or more characters in the range "
0—9
"- Optionally, the following parts, in exactly the following order:
- a "
e
" character or "E
" character- optionally, a "
-
" character or "+
" character- One or more characters in the range "
0—9
".
关于html - 为什么类型为 "number"的 html 输入允许在字段中输入字母 'e'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31706611/