Posts Tagged ‘Avoid round trip in MVC’

Enable client side validation

July 19, 2015 Leave a comment

By default client side scripting disabled by default. To enable Client side scripting in MVC you need to follow the below 2 steps.

Step 1:

To Enable Client Side validation in web.config

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

Step 2:

– Include reference of javascript files in the masterpage
– Avoid adding reference in each and every View page

Add the following references in Masterpage

<script src=”~/Scripts/jquery-1.8.2.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>

The order of adding reference are also important.

Now we can able to validate in client side by avoiding round trip to server side.

%d bloggers like this: