from django import forms
from captcha.fields import ReCaptchaField

class AddGuBook(forms.Form):
	username = forms.CharField()
	email = forms.EmailField()
	homepage = forms.URLField(required = False)
	text = forms.CharField(widget = forms.Textarea)
	image = forms.ImageField(required = False)
	captcha = ReCaptchaField()

	def clean_username(self):
		username = self.cleaned_data['username']
		if not username.isalnum():
			raise forms.ValidationError("Not digits or alphabetic!")
		return username
	def clean_text(self):
		text = self.cleaned_data['text']
		if text.find('<') > -1 or text.find('lt;') > -1:
			raise forms.ValidationError("HTML-tag baned!")
		return text


class RecaptchaForm(AddGuBook):
    captcha = ReCaptchaField()


@@ -59,16 +59,26 @@
 chaField
+%0Aimport re
 %0A%0Aclass 
@@ -401,33 +401,101 @@
 %5D%0A%09%09
-if not username.isalnum()
+regexp_name = re.compile('%5Ba-zA_Z0-9%5D+')%0A%09%09if regexp_name.match(username).group() != username
 :%0A%09%09

Update gba/forms.py