Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 579
ssssergey Avatar asked Mar 26 '16 21:03

ssssergey


People also ask

What does flask WTF stand for?

WTF stands for WT Forms which is intended to provide the interactive user interface for the user. The WTF is a built-in module of the flask which provides an alternative way of designing forms in the flask web applications.

What is Stringfield?

The string field is used for allowing users to enter unformatted text information into your form in a limited fashion. Creating multiple strings is useful for collecting directed information, such as answers from your user requiring single words or brief sentences.


2 Answers

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.

like image 169
davidism Avatar answered Sep 24 '22 18:09

davidism


Ok. I found it.

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

like image 36
ssssergey Avatar answered Sep 22 '22 18:09

ssssergey