Saturday, August 31, 2013

Re: Form validation number and text only no space mac 4 numbers

Change you regex to: r'^[a-zA-Z0-9]{1,4}'


On Sat, Aug 31, 2013 at 5:41 PM, Gerd Koetje <deonlinefotograaf@gmail.com> wrote:
Hi all,

How do i valididate for this?

- numbers and text only , no spaces
- max 4 number




    def clean_profielnaam(self):
        data = self.cleaned_data['profielnaam']
        if not re.match(r'^[a-z][0-9]+', data):
            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+unsubscribe@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.

--
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+unsubscribe@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.

No comments:

Post a Comment