<appSettings> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> </appSettings>
<script src="/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script> <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script> <script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
在MVC2中是默认不启用客户端验证(在MVC3及以后的版本,是默认启用),首先在Web.config中配置,并在视图中引入jQuery验证库