Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input type='number' new validation removes leading zeros and formats number in Safari for iPhone iOS5 and latest Safari for Mac

The latest Safari for MacOS and the one that comes in iOS5 has some extra validation that causes problems if the text field is not a phone number.

Case: Input text field with type="numeric" attribute.

Problems: 1) Number gets formatted as a phone number. E.g. if I type '012345678' it gets formatted as '012 345 678'

2) Leading zeros are being removed. E.g. '01234567' gets formatted as '1234567'

I could just remove the type="numeric" attribute on my text field and probably the problem will disappear, but I would really like to use the numeric keypad for this text field instead of the normal keyboard on the iPhone.

Any ideas how to fix this?

Many thanks

like image 990
tif Avatar asked Oct 20 '11 08:10

tif


1 Answers

I change type="number" to type="tel" and works fine. I did some quick testing and have not found any validation or auto-formatting of the text either.

like image 194
tif Avatar answered Nov 09 '22 16:11

tif