HTML5 - input=number and incompatible browsers

拈花ヽ惹草 提交于 2019-11-29 05:41:40

问题


I want to use the html5 element <input type="number"> on my website, but i want to know what happens to this field in browsers that do not support this feature? Is it than a classic <input type="text"> field for those browsers?


回答1:


When a browser does not recognize a particular type value for an <input>, it reverts to it's default value, which is text. So, all of the following are equivalent on browsers that do not support type="number":

<input type="number">
<input type="somevaluethatdoesntexist">
<input type="text">
<input>

For browsers that do support type="number", the number <input> will be displayed instead of the text <input>.

Read more about the type attribute in the HTML Specification.




回答2:


Refer to

  • W3 - Input Types
  • W3 - Input Type Number
  • W3Schools - HTML 5 Input Types

Open this Example on IE and Chrome and see the difference.

Supported Browsers:

  • Opera
  • Safari
  • Chrome

If HTML 5 Input Types are not supported on a browser, they will behave as regular text fields.




回答3:


Caution, while older browsers ignore and default to "text", many newer browsers simply do the wrong thing. See: What models of Samsung smartphones have missing period for html5 input type="number"?



来源:https://stackoverflow.com/questions/10521445/html5-input-number-and-incompatible-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!