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

自作多情 提交于 2019-12-01 15:26:52

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/7833257/input-type-number-new-validation-removes-leading-zeros-and-formats-number-in-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!