简体   繁体   English

如何在 WTForms 中使用“电话”、“号码”或其他输入类型?

[英]How do I use “tel”, “number”, or other input types in WTForms?

I want to use a phone number field in my form.我想在表单中使用电话号码字段。 What I need is when this field is tapped on Android phone, not general keyboard, but digital only appears.我需要的是当这个字段在 Android 手机上点击时,不是通用键盘,而是只出现数字。

I learned that this can be achieved by using <input type="tel" or <input type="number" .我了解到这可以通过使用<input type="tel"<input type="number"

How do I use the tel or number input types in WTForms?如何在 WTForms 中使用电话或数字输入类型?

This appears to be missing from the WTForms docs, but there are field definitions for all the input types added in HTML 5.这似乎在 WTForms 文档中缺失,但 HTML 5 中添加的所有输入类型都有字段定义。

from wtforms.fields.html5 import TelField

phonenumber = TelField()

Until they're added to the docs, here's their definition in the code .在将它们添加到文档之前, 这是它们在代码中的定义

Ok.好的。 I found it.我找到了。

IntegerField(widget = widgets.Input(input_type="tel")) IntegerField(widget = widgets.Input(input_type="tel"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM