HTML5输入类型=数字删除前导零 [英] HTML5 Input type=number removes leading zero

查看:122
本文介绍了HTML5输入类型=数字删除前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome 15中,当使用元素作为文本字段时,即使输入的数字未破坏验证规则(例如,最小,最大),前导零(例如011)也会被删除。是否有一个属性来强制零点在焦点失去后留在现场?此应用程序为数字数据,例如国际电话前缀。

textpattern =[0-9] *...



应该为你做。会在iPhone上显示数字键盘和我测试过的更好的Android手机。


In Chrome 15, when using the element as a text field, leading zeros (e.g. 011) are removed even if the number entered does not break the validation rules (e.g. min, max). Is there an attribute to force the zero to remain in the field after it loses focus? The application for this is numeric data such as international phone prefixes.

解决方案

<input type="text" pattern="[0-9]*" ...

that should do it for you. Will bring up the numeric keypad on iPhone and the nicer Android phones I've tested on.

这篇关于HTML5输入类型=数字删除前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆