- June 5, 2008
- newforms checkbox forms validation clean booleanfield agreement
- 5 (after 5 ratings)
Creating new field to handle checkbox validation in situations where the checkbox must be checked, as in check to agree to terms and such.
1 2 3 4 5 6 7 8 9
from django.newforms.fields import BooleanField from django.newforms import ValidationError class AgreementField(BooleanField): def clean(self, value): super(AgreementField, self).clean(value) if not value: raise ValidationError("You must agree to continue.") else: return value