在MVC4中处理DataAnnoations验证需要jquery.validate.js文件吗?
我从项目中删除了此文件,验证无效,是否对DataAnnonations验证起了重要作用?
答案 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。