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

后端 未结 2 1248
囚心锁ツ
囚心锁ツ 2021-01-06 01:32

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.

I learned t

相关标签:
2条回答
  • 2021-01-06 01:54

    This appears to be missing from the WTForms docs, but there are field definitions for all the input types added in HTML 5.

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

    Until they're added to the docs, here's their definition in the code.

    0 讨论(0)
  • 2021-01-06 02:12

    Ok. I found it.

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

    0 讨论(0)
提交回复
热议问题