Where is my mistake?
mobile = forms.IntegerField(
label='Mobile',
widget=forms.NumberInput(attrs={
'class': 'form-control',
'required': 'required'
}),
error_messages={
'invalid': 'Required',
}
)
def clean_mobile(self):
mobile = self.cleaned_data['mobile']
if not re.match('^((?!([0-8]))[0-9]{9})$', str(mobile)):
self.add_error('mobile', 'Wrong number')
return mobile
Always returns False
!