0

In an MVC project I need to validate number of pages of a book using Data Annotations method like following coding sample. Number of pages can be an even integer anything between 0 to 9998 inclusive.

[DisplayName("Pages (Including Cover):")]
[RegularExpression("reg_ex_string",ErrorMessage="Invalid Value")]
public int pages { get; set; }

Your help would be much appreciated.

4

1 回答 1

4

零到三位数字后跟 0、2、4、6 或 8:

^\d{0,3}[02468]$
于 2013-09-16T11:39:38.073 回答