Is there a way to stop inserting Mobile Safari commas into numeric fields in HTML forms?

I have a website that contains a form that allows users to enter credit card information. The fields for the card number, issue number, CVC number and the amount they want to deposit use an HTML input field of type "number".

The updated Mobile Safari, which ships with iOS 5, automatically inserts commas into numbers in the number input boxes. This not only looks silly in the CC number, but also violates my verification. Is there any way to stop this?

The sole purpose of using a “number” as opposed to a “text” is to force iOS and Android to display only a keyboard with numbers, not a full keyboard.

I tried using text input with a pattern set to "[0-9] *". This calls up the keyboard of numbers on iOS, but not on Android. It also does not allow you to enter a number with a decimal point.

I would be very grateful for any suggestions :)

thanks

+7
source share
3 answers

I changed my meaning from “number” to “tel”, and I no longer saw the problem occur.

+9
source

You are close - all you have to do is set the pattern to "[0-9] *" and save the type as "number".

+5
source

I have the same problem. I think this is due to the format of the region in your settings. You can set the type to "text":

type = text pattern = "[0-9] {1,4} (\. [0-9] {2})?"

for a value from 0 to 9999.99. However, this solution does not start the keyboard with the number on iOS 5. Or save the regional settings (dot / comma) and set:

type = number step = "0.01" max = "9999.99"

for decimal values ​​from 0 to 9999.99. In addition, the inability to check or clear fields with the “required” attribute does not prevent the form from being submitted in Safari 5.1 (OS X and iOS).

+1
source

All Articles