Is there a consistent way across browsers to hide the new spin boxes that some browsers (such as Chrome) render for HTML input of type number? I am looking for a CSS or JavaScript method to prevent the up/down arrows from appearing.
<input id="test" type="number">
According to Apple’s user experience coding guide for mobile Safari, you can use the following to display a numeric keyboard in the iPhone browser:
A
pattern
of\d*
will also work.Try using
input type="tel"
instead. It pops up a keyboard with numbers, and it doesn’t show spin boxes. It requires no JavaScript or CSS or plugins or anything else.Not what you asked for, but I do this because of a focus bug in WebKit with spinboxes:
It might give you an idea to help with what you need.
Firefox 29 currently adds support for number elements, so here's a snippet for hiding the spinners in webkit and moz based browsers:
I've encountered this problem with a
input[type="datetime-local"]
, which is similar to this problem.And I've found a way to overcome this kind of problems.
First, you must turn on chrome's shadow-root feature by "DevTools -> Settings -> General -> Elements -> Show user agent shadow DOM"
Then you can see all shadowed DOM elements, for example, for
<input type="number">
, the full element with shadowed DOM is:And according to these info, you can draft some CSS to hide unwanted elements, just as @Josh said.