HTML5 - input=number and incompatible browsers
Asked Answered
O

3

23

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?

Osteomalacia answered 9/5, 2012 at 17:52 Comment(2)
you could always just try it and seeToscano
Torben, did one of the posts below answer your question? If so, could you accept it? (See How do I ask a question here? in the FAQ.) If not, what additional information do you require that isn't provided below?Storyteller
S
29

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.

Storyteller answered 9/5, 2012 at 18:3 Comment(0)
G
5

Refer to

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.

Geanine answered 9/5, 2012 at 17:59 Comment(3)
If you're going to specify W3C, link to the spec, not w3schools.com (which has no affiliation).Storyteller
This war against W3Schools has to stop. So what if they're not affiliated with W3C? A bunch of answers/comments etc mention random forums, blogs and pretty much any kind of site, and they're not voted down. Then we see people voting down solely based on the fact that there's a link to W3schools, even tho its a valid answer..Greening
@MilkyWayJoe, first off, a lot of the time W3Schools is voted down because the particular page linked to has invalid information. In this case, Siva had "W3C - HTML 5 Input Types" linked to W3Schools, which is incorrect information as W3C and W3Schools are not affiliated (so I voted down to avoid confusion, not just because W3Schools was linked to, which I have removed because the answer has been updated accordingly). However, there are some people who vote down W3Schools solely because it's W3Schools, which I don't agree with, but this was not the case for this answer.Storyteller
C
2

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"?

Curable answered 2/6, 2014 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.