我有一个具有多个验证规则的模型:
[Required(ErrorMessage = "Number must be enter")]
[RegularExpression("^[0-9]{1,10}$", ErrorMessage = "Your must be enter only integer number between 0-10 simvols")]
public int Number
{
get { return number; }
set { number = value; }
}
所以我的验证不起作用。我检查了我的代码,但找不到我做错的地方。这是我的视图模板的一部分:
<% using (Html.BeginForm())
{%>
<%: Html.ValidationSummary(true) %>
<div class="editor-label">
<p class="number">
Enter number</p>
<%: Html.TextBoxFor(model => model.Number, new {@class = "txtNumber"})%>
<%: Html.ValidationMessageFor(model => model.Number) %>
</div>
<p>
<input type="submit" value="Calculate" class="button" />
</p>
<% } %>