【发布时间】:2012-05-15 20:50:04
【问题描述】:
这是我的模特:
[RegularExpression(@"^08[589][0-9]{8}$", ErrorMessage = "Invalid Number!")]
public string Phone { get; set; }
[ForeignKey]
public long PhoneType { get; set; } // 1-CellPhone , 2-Phone
所以我想更改RegularExpression Validation by Change PhoneType 如果我想说更具体:
如果用户从DropDownList中选择CellPhone,则验证为
[RegularExpression(@"^08[589][0-9]{8}$", ErrorMessage = "Invalid Number!")]
如果选择Phone,则验证是
[RegularExpression("^[1-9][0-9]{9}$", ErrorMessage = "Invalid Number!")]
你有什么建议?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 validation validationattribute