Based on this answer here: Using range in regex for Arabic letters
I want to validate a Form field to allow only Arabic characters. My Form is:
fullname_arabic = forms.CharField(
label=_('Arabic Full Name'),
widget=widgets.TextInput(),
help_text=_('Please enter your arabic name'),
)
The Form has a clean
method which is giving me problems to make it work. Actually it is allowing any character:
def clean_fullname_arabic(self):
fullname_arabic = self.cleaned_data['fullname_arabic']
if not re.match(r'[\u0627-\u064a]+$', fullname_arabic):
raise forms.ValidationError("Only Arabic chars")
I know the problem must be in my Regex, but I am confusing concepts here and can't make it work.