diff --git a/django/contrib/localflavor/at/forms.py b/django/contrib/localflavor/at/forms.py index 52721368e0..262641bf1f 100644 --- a/django/contrib/localflavor/at/forms.py +++ b/django/contrib/localflavor/at/forms.py @@ -16,13 +16,13 @@ class ATZipCodeField(RegexField): """ A form field that validates its input is an Austrian postcode. - Accepts 4 digits. + Accepts 4 digits (first digit must be greater than 0). """ default_error_messages = { 'invalid': _('Enter a zip code in the format XXXX.'), } def __init__(self, max_length=None, min_length=None, *args, **kwargs): - super(ATZipCodeField, self).__init__(r'^\d{4}$', + super(ATZipCodeField, self).__init__(r'^[1-9]{1}\d{3}$', max_length, min_length, *args, **kwargs) class ATStateSelect(Select): diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt index d4c9dca495..1e565a58b1 100644 --- a/docs/ref/contrib/localflavor.txt +++ b/docs/ref/contrib/localflavor.txt @@ -243,7 +243,8 @@ Austria (``at``) .. class:: at.forms.ATZipCodeField - A form field that validates its input as an Austrian zip code. + A form field that validates its input as an Austrian zip code, with the + format XXXX (first digit must be greater than 0). .. class:: at.forms.ATStateSelect diff --git a/tests/regressiontests/forms/localflavor/at.py b/tests/regressiontests/forms/localflavor/at.py index 3fa50ac4df..11e0cd4ec1 100644 --- a/tests/regressiontests/forms/localflavor/at.py +++ b/tests/regressiontests/forms/localflavor/at.py @@ -28,6 +28,8 @@ class ATLocalFlavorTests(LocalFlavorTestCase): '8020': '8020', } invalid = { + '0000' : error_format, + '0123' : error_format, '111222': error_format, 'eeffee': error_format, }