mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 07:28:24 -04:00
Use correct HTML 5 input types
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.
This commit is contained in:
@@ -9,6 +9,7 @@ from wtforms import (
|
|||||||
FileField,
|
FileField,
|
||||||
RadioField
|
RadioField
|
||||||
)
|
)
|
||||||
|
from wtforms.fields.html5 import EmailField, TelField
|
||||||
from wtforms.validators import DataRequired, Email, Length, Regexp
|
from wtforms.validators import DataRequired, Email, Length, Regexp
|
||||||
|
|
||||||
from app.main.validators import Blacklist, CsvFileValidator
|
from app.main.validators import Blacklist, CsvFileValidator
|
||||||
@@ -23,14 +24,14 @@ from app.main.utils import (
|
|||||||
def email_address():
|
def email_address():
|
||||||
gov_uk_email \
|
gov_uk_email \
|
||||||
= "(^[^@^\\s]+@[^@^\\.^\\s]+(\\.[^@^\\.^\\s]*)*.gov.uk)"
|
= "(^[^@^\\s]+@[^@^\\.^\\s]+(\\.[^@^\\.^\\s]*)*.gov.uk)"
|
||||||
return StringField('Email address', validators=[
|
return EmailField('Email address', validators=[
|
||||||
Length(min=5, max=255),
|
Length(min=5, max=255),
|
||||||
DataRequired(message='Email cannot be empty'),
|
DataRequired(message='Email cannot be empty'),
|
||||||
Email(message='Enter a valid email address'),
|
Email(message='Enter a valid email address'),
|
||||||
Regexp(regex=gov_uk_email, message='Enter a gov.uk 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):
|
def pre_validate(self, form):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user