gpt4 book ai didi

html - 为什么类型为 "number"的 html 输入允许在字段中输入字母 'e'?

转载 作者:IT老高 更新时间:2023-10-28 11:06:42 26 4
gpt4 key购买 nike

我有以下 html5 输入元素:

<input type="number">

为什么这个输入允许在输入字段中输入字符“e”?无法输入其他字母字符(如预期的那样)

使用 chrome v. 44.0.2403.107

下面的例子来看看我的意思。

<input type="number">

最佳答案

因为这正是 the spec说它应该工作。输入的数字可以接受floating-point numbers ,包括负号和 eE 字符(其中指数是 eE 之后的数字):

A floating-point number consists of the following parts, in exactly the following order:

  1. Optionally, the first character may be a "-" character.
  2. One or more characters in the range "0—9".
  3. Optionally, the following parts, in exactly the following order:
    1. a "." character
    2. one or more characters in the range "0—9"
  4. Optionally, the following parts, in exactly the following order:
    1. a "e" character or "E" character
    2. optionally, a "-" character or "+" character
    3. One or more characters in the range "0—9".

关于html - 为什么类型为 "number"的 html 输入允许在字段中输入字母 'e'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31706611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com