Ticket #7463: forms.py.patch

File forms.py.patch, 960 bytes (added by kevin@…, 16 years ago)

patch: allow forward slash as areacode delimiter

  • contrib/localflavor/us/forms.py

     
    88from django.utils.translation import ugettext
    99import re
    1010
    11 phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
     11phone_digits_re = re.compile(r'^(?:1-?)?(\d{3})[-/\.]?(\d{3})[-\.]?(\d{4})$')
    1212ssn_re = re.compile(r"^(?P<area>\d{3})[-\ ]?(?P<group>\d{2})[-\ ]?(?P<serial>\d{4})$")
    1313
    1414class USZipCodeField(RegexField):
     
    2929        super(USPhoneNumberField, self).clean(value)
    3030        if value in EMPTY_VALUES:
    3131            return u''
    32         value = re.sub('(\(|\)|\s+)', '', smart_unicode(value))
     32        value = re.sub('(\(|/|\)|\s+)', '', smart_unicode(value))
    3333        m = phone_digits_re.search(value)
    3434        if m:
    3535            return u'%s-%s-%s' % (m.group(1), m.group(2), m.group(3))
Back to Top