summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-01-28 14:12:56 +0100
committerClaude Paroz <claude@2xlibre.net>2013-01-28 22:10:50 +0100
commit4f16376274a4e52074722c615fccef5fac5f009a (patch)
tree06758241da714e07d2cda1a97c7c6f12720e352a /django
parentc47fa3b4814240bb47342a4446d40ea83bd3ed19 (diff)
Added HTML5 email input type
Refs #16630.
Diffstat (limited to 'django')
-rw-r--r--django/forms/fields.py7
-rw-r--r--django/forms/widgets.py6
2 files changed, 10 insertions, 3 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index d16b501baa..8a3dbfeb49 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -18,10 +18,12 @@ from io import BytesIO
from django.core import validators
from django.core.exceptions import ValidationError
from django.forms.util import ErrorList, from_current_timezone, to_current_timezone
-from django.forms.widgets import (TextInput, PasswordInput, HiddenInput,
+from django.forms.widgets import (
+ TextInput, PasswordInput, EmailInput, HiddenInput,
MultipleHiddenInput, ClearableFileInput, CheckboxInput, Select,
NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput,
- SplitDateTimeWidget, SplitHiddenDateTimeWidget, FILE_INPUT_CONTRADICTION)
+ SplitDateTimeWidget, SplitHiddenDateTimeWidget, FILE_INPUT_CONTRADICTION
+)
from django.utils import formats
from django.utils.encoding import smart_text, force_str, force_text
from django.utils.ipv6 import clean_ipv6_address
@@ -487,6 +489,7 @@ class RegexField(CharField):
regex = property(_get_regex, _set_regex)
class EmailField(CharField):
+ widget = EmailInput
default_error_messages = {
'invalid': _('Enter a valid email address.'),
}
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 303844d44b..f201e914dd 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -22,7 +22,7 @@ from django.utils.safestring import mark_safe
from django.utils import datetime_safe, formats, six
__all__ = (
- 'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'PasswordInput',
+ 'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'EmailInput', 'PasswordInput',
'HiddenInput', 'MultipleHiddenInput', 'ClearableFileInput',
'FileInput', 'DateInput', 'DateTimeInput', 'TimeInput', 'Textarea', 'CheckboxInput',
'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect',
@@ -251,6 +251,10 @@ class TextInput(Input):
super(TextInput, self).__init__(attrs)
+class EmailInput(TextInput):
+ input_type = 'email'
+
+
class PasswordInput(TextInput):
input_type = 'password'