form 字段验证

models.py
cellphone = models.CharField('电话', max_length=20, validators=[CellPhoneValidator])


from django.core.validators import RegexValidator
CellPhoneValidator = RegexValidator(r'^\+?\d[\d\-]+\d$',
                                  message=u'请输入有效电话号码')

你可能感兴趣的:(form 字段验证)