I’m building a form using jQuery Mobile but if I use an input filed with the attribute type=”number” the numbers entered get formatted using the thousands convention
example:
if I enter 1234567
the number will be converted in to 1,234,567
<input type="number" name="number" id="number" value="">
is there a way to avoid this?
thanks
Most browsers do not do that, but WebKit-based ones (like Chrome), does. Incorrectly, I might add, since I believe it is stated in the HTML5 specification that no such formatting should be done.
This is a major problem for me when it comes to HTML5 input items; that they are not customizable enough and almost unusable in any sort of production environment because of different client behavior. But this (I hope) will get changed as the specification becomes more mature, so that the developer can decide things instead of the browser.
Another example is how
requiredworks on some browsers, and how the error message is decided on.The solution to your problems is to not use
type="number", and instead go back to usingtype="text"and adding the attributepatternwith the regex value of"[0-9]*"which will make it show up as a number input at least on Apple phones. Not on Android, however, I think.What you could do is check on the requests what kind of client it is, and use different methods depending on that. Like using
type="text" pattern="[0-9]*"for iPhone and desktop computers, andtype="number"for Android.