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

2019-02-17 14:28发布

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 that this can be achieved by using <input type="tel" or <input type="number".

How do I use the tel or number input types in WTForms?

2条回答
Luminary・发光体
2楼-- · 2019-02-17 15:04

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()
查看更多
虎瘦雄心在
3楼-- · 2019-02-17 15:27

Ok. I found it.

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

查看更多
登录 后发表回答