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'請輸入有效電話號碼')
相關文章
相關標籤/搜索