我在 ASP.NET MVC 3/Razor 中使用客户端验证(不显眼),我<textarea>
通过使用 Html.EditorFor 并指定 DataType.MultilineText 让它工作,但 Html.TextAreaFor 不应该也有客户端验证吗?
[Required(ErrorMessage = "Foo")]
public string Message { get; set; }
// Does add client-side validation
@Html.TextBoxFor(m => m.Message)
// Does NOT add client-side validation
@Html.TextAreaFor(m => m.Message)
[Required(ErrorMessage = "Foo")]
[DataType(DataType.MultilineText)]
public string Message { get; set; }
// Does add client-side validation (and multiline)
@Html.EditorFor(m => m.Message)
// Does NOT add client-side validation
@Html.TextAreaFor(m => m.Message)
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />