Wednesday, June 26, 2013

Enable/Disable Client Side Validation for the Entire Application in ASP.NET MVC

To enable client validation below scripts are required to added to the view.

<script src="@Url.Content("~/Scripts/jquery-1.6.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>

When we create an internet application in MVC3/MVC4 by default below settings are enabled in web.config.

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

To disable client side validation for the entire application we can set above settings to false.

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

No comments:
Write comments
Recommended Posts × +