HTML5 输入类型号与电话

2022-01-17 00:00:00 numbers types html html-input

我正在努力将一些表单输入更新为 HTML5.我对验证数据不感兴趣,就像在移动设备上使用数字键盘一样.输入类型tel"似乎可以满足我的需求,我在 iPad/移动设备上获得了数字键盘.输入类型数字"也会给我数字键盘,但它还包括我不想要的微调框.

I'm working on updating some form inputs to HTML5. I'm not interested in validating the data so much as having the numeric key pad on mobile devices. Input type 'tel' seems to do what I want, I get the numeric keypad on iPad/mobile. Input type 'number' will also give me the numeric keypad, but it also includes the spinner box which I don't want.

我想知道在信用卡输入上使用 type="tel" 是否安全?或者我应该使用 type="number" 并尝试以某种方式禁用微调器.我读到禁用微调器会使 Chrome 崩溃,这不是我愿意做出的权衡.

What I want to know is if it's safe to use type="tel" on a credit card input? Or should I use type="number" and try to disable the spinner somehow. I was reading that disabling the spinner can crash Chrome which isn't a trade off I'm willing to make.

此外,目前我们为移动用户和非移动用户使用完全相同的网站.

Also, for the time being we're using the exact same site for mobile and non-mobile users.

推荐答案

我看了这个并且刚刚在我的 Xoom 上使用内置浏览器和 FF 移动(使用桌面 UA 字符串) 并且 tel 输入似乎可以正常工作.

I looked at this and just tried this on my Xoom with the built in browser and FF mobile (with a desktop UA string) and the tel input would seem to work just fine for this.

相关文章