views:

21

answers:

1

In my form I have a following regex field :

code = forms.RegexField(regex=r'^\d{2}[-]\d{3}', max_length=6, widget=forms.TextInput(attrs=attrs_dict), label="Postal code")

how to create clean method for this field checking if the regex requirements are met ? I'd like to have a custom message here, not django's built in (if it gives any).

A: 

Your question seems similar to this: http://stackoverflow.com/questions/1481771/django-override-default-form-error-messages

Piotr Duda