like this?

import string
accepted = string.letters + string.digits
max_numbers = 4

def test(word):
    numbers = 0
    for c in word:
        if c.isdigit():
            numbers += 1
        if not c in accepted or numbers > max_numbers:
           return False
        return True

# Create profiel

# profielnaam
class ProfielenForm(forms.ModelForm):




    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if test(data) is False:
            raise forms.ValidationError("Je mag alleen tekst en cijfers 
gebruiken en geen spaties")

        return data

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to