Ticket #7463: forms.py.patch
File forms.py.patch, 960 bytes (added by , 16 years ago) |
---|
-
contrib/localflavor/us/forms.py
8 8 from django.utils.translation import ugettext 9 9 import re 10 10 11 phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[- \.]?(\d{3})[-\.]?(\d{4})$')11 phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-/\.]?(\d{3})[-\.]?(\d{4})$') 12 12 ssn_re = re.compile(r"^(?P<area>\d{3})[-\ ]?(?P<group>\d{2})[-\ ]?(?P<serial>\d{4})$") 13 13 14 14 class USZipCodeField(RegexField): … … 29 29 super(USPhoneNumberField, self).clean(value) 30 30 if value in EMPTY_VALUES: 31 31 return u'' 32 value = re.sub('(\(| \)|\s+)', '', smart_unicode(value))32 value = re.sub('(\(|/|\)|\s+)', '', smart_unicode(value)) 33 33 m = phone_digits_re.search(value) 34 34 if m: 35 35 return u'%s-%s-%s' % (m.group(1), m.group(2), m.group(3))