You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
445 B

11 years ago
from django.forms import CharField
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.core.validators import EMPTY_VALUES
7 years ago
11 years ago
class DigitField(CharField):
7 years ago
def clean(self, value):
super(DigitField, self).clean(value)
11 years ago
7 years ago
if value not in EMPTY_VALUES and not value.isdigit():
raise ValidationError(_('Please enter only digits.'))
11 years ago
7 years ago
return value