Html 现在可以使用 <input type="tel"/> 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2813997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:03:06  来源:igfitidea点击:

Is it okay to use <input type="tel"/> now?

htmlmobile-websitebackwards-compatibility

提问by Michael

I'm working on a mobile phone web app and I have several text fields that could benefit from <input type="tel"/>. iPhones will adjust the keyboard for the user, but I'm worried about breaking backwards compatibility. What I'm hoping is that browsers/phone that support this can assist the user and other browser will fall back to a standard text field? Is this an acceptable practice? Does it even work?

我正在开发一个手机网络应用程序,我有几个文本字段可以从<input type="tel"/>. iPhone 会为用户调整键盘,但我担心会破坏向后兼容性。我希望支持此功能的浏览器/电话可以帮助用户,而其他浏览器将退回到标准文本字段?这是可以接受的做法吗?它甚至有效吗?

回答by animuson

Yes, any unsupported type will revert to the 'type=text' format.

是的,任何不受支持的类型都将恢复为“type=text”格式。

I found a good page which lists out all the existing input types. I tried looking at it from different browsers, a bit interesting. Don't know if it will help you or not.

我找到了一个很好的页面,其中列出了所有现有的输入类型。我试着从不同的浏览器看它,有点有趣。不知道对你有没有帮助。

http://miketaylr.com/pres/html5/forms2.html

http://miketaylr.com/pres/html5/forms2.html

回答by el.pescado

Browsers will fall back to type="text" when they encounter unsupported input type. So I think it's OK to use type="tel".

浏览器在遇到不支持的输入类型时会回退到 type="text"。所以我认为使用 type="tel" 是可以的。

回答by Hank Gay

Short answer: yes. As @el.pescado mentions, browsers fall back to type=textwhen they don't undertand the type. For more info about the other cool features you get from HTML5 forms, check out A Form of Madness, which is the forms chapter in Dive Into HTML5.

简短的回答:是的。正如@el.pescado 提到的,浏览器回退到type=text他们不理解类型的时候。有关您从 HTML5 表单获得的其他很酷功能的更多信息,请查看疯狂的表单,这是深入 HTML5 中的表单章节。