From 6b4ede629cfb938cac93aabaa1b81d7920d4a63e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 15 Feb 2016 13:13:57 +0000 Subject: [PATCH] Use correct HTML 5 input types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These give devices a hint (although don’t mandate them) to use a numeric keypad, or a keypad with the `@` symbol visible when entering phone numbers or email addresses. --- app/main/forms.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index a5e7f739c..d97784863 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -9,6 +9,7 @@ from wtforms import ( FileField, RadioField ) +from wtforms.fields.html5 import EmailField, TelField from wtforms.validators import DataRequired, Email, Length, Regexp from app.main.validators import Blacklist, CsvFileValidator @@ -23,14 +24,14 @@ from app.main.utils import ( def email_address(): gov_uk_email \ = "(^[^@^\\s]+@[^@^\\.^\\s]+(\\.[^@^\\.^\\s]*)*.gov.uk)" - return StringField('Email address', validators=[ + return EmailField('Email address', validators=[ Length(min=5, max=255), DataRequired(message='Email cannot be empty'), Email(message='Enter a valid email address'), Regexp(regex=gov_uk_email, message='Enter a gov.uk email address')]) -class UKMobileNumber(StringField): +class UKMobileNumber(TelField): def pre_validate(self, form): try: