html5 – 为什么类型为“number”的html输入允许在字段中输入字母“e”?

前端之家收集整理的这篇文章主要介绍了html5 – 为什么类型为“number”的html输入允许在字段中输入字母“e”?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下html5输入元素:
<input type="number">

为什么此输入允许在输入字段中输入字符“e”?不能输入其他字母字符(如预期)

使用chrome v。44.0.2403.107

看看我的意思:http://www.w3schools.com/html/tryit.asp?filename=tryhtml_input_number

解决方法

因为这正是070​​00说它应该工作。数字输入可以接受 floating point numbers包括负号和e或E字符:

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,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“.

猜你在找的HTML5相关文章