【问题标题】:How do I use "tel", "number", or other input types in WTForms?如何在 WTForms 中使用“tel”、“number”或其他输入类型?
【发布时间】:2016-07-14 10:43:18
【问题描述】:

我想在表单中使用电话号码字段。我需要的是在Android手机上点击此字段时,不是通用键盘,而是仅出现数字。

我了解到这可以通过使用<input type="tel"<input type="number" 来实现。

如何在 WTForms 中使用 tel 或 number 输入类型?

【问题讨论】:

    标签: python flask wtforms flask-wtforms


    【解决方案1】:

    WTForms 文档中似乎没有此内容,但 HTML 5 中添加的所有输入类型都有字段定义。

    from wtforms.fields.html5 import TelField
    
    phonenumber = TelField()
    

    直到它们被添加到文档中,here's their definition in the code

    【讨论】:

      【解决方案2】:

      好的。我找到了。

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

      【讨论】:

        猜你喜欢
        • 2015-05-06
        • 2012-09-09
        • 2017-01-10
        • 2021-01-04
        • 2015-05-05
        • 2018-07-05
        • 1970-01-01
        • 1970-01-01
        • 2021-11-11
        相关资源
        最近更新 更多