如何在WTForms中使用"tel","number"或其他输入类型? [英] How do I use "tel", "number", or other input types in WTForms?

查看:97
本文介绍了如何在WTForms中使用"tel","number"或其他输入类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

I learned that this can be achieved by using <input type="tel" or <input type="number".

如何在WTForms中使用电话或数字输入类型?

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

推荐答案

WTForms文档似乎没有提供此功能,但是HTML 5中添加了所有输入类型的字段定义.

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.

这篇关于如何在WTForms中使用"tel","number"或其他输入类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆