MVC4项目中的jquery.validate.js文件

时间:2013-08-01 06:09:32

标签: asp.net-mvc-4

在MVC4中处理DataAnnoations验证需要jquery.validate.js文件吗?

我从项目中删除了此文件,验证无效,是否对DataAnnonations验证起了重要作用?

1 个答案:

答案 0 :(得分:0)

如果您想使用DataAnnotations并且客户端验证包括以下脚本。

<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>

它们也可以作为nuget包使用。

因此需要jquery.validate.js,但也需要其他文件。

确保

<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

在webconfig中设置为true。