Jquery 在MVC4中,对Textarea不起作用的低调验证
我面临着一个关于MVC4中使用不引人注目的验证插件进行客户端验证的问题。验证可以在文本框for中正常工作,但不能在文本区域for中工作。我尝试改用EditorFor,但没有在工具提示中显示验证(如图所示) 型号Jquery 在MVC4中,对Textarea不起作用的低调验证,jquery,asp.net-mvc-4,validation,client-side,unobtrusive-validation,Jquery,Asp.net Mvc 4,Validation,Client Side,Unobtrusive Validation,我面临着一个关于MVC4中使用不引人注目的验证插件进行客户端验证的问题。验证可以在文本框for中正常工作,但不能在文本区域for中工作。我尝试改用EditorFor,但没有在工具提示中显示验证(如图所示) 型号 [Required] [Display(Name = "New Message")] [DataType(DataType.MultilineText)] public string txtMessage { get; set; } 捆绑配置 bundles
[Required]
[Display(Name = "New Message")]
[DataType(DataType.MultilineText)]
public string txtMessage { get; set; }
捆绑配置
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive-ajax.min.js",
"~/Scripts/jquery.validate.min.js",
"~/Scripts/jquery.validate.unobtrusive.min.js"));
查看
@using (Html.BeginForm("SaveBoardTaskMessage", "Task", FormMethod.Post, new { id = "BoardTaskMessageForm", enctype = "multipart/form-data" })){
@Html.TextAreaFor(model => model.txtMessage, new { @cols = 40, @rows = 6, @style = "font-family: inherit;resize: none;width:404px;" })
@Html.ValidationMessageFor(model => model.txtMessage)
}
尝试用
编辑器for
替换文本区域for
。由于您的模型已经设置了多行标志,这应该不会影响您的UI,但它应该能够解决TextAreaFor
的潜在缺陷(某些版本已经记录在案)