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'请输入有效电话号码')
相关文章
相关标签/搜索