How to use client side jquery validation in asp.net mvc 3

We can directly apply the validation by using jquery.validate.unobtrusive.min.js without using the model class.
By adding html markup you can enable the client side validation.

In your View this is how it looks like in your input text.

First add the jquery scripts.

<script type="text/javascript" src="/Scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.min.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.unobtrusive.min.js"></script>

Then your input text

<input type="text" name="name" id="name" value="val" data-val="true" data-val-required="required" />

There very simple classic approach ^_^
Happy Coding

 

blog comments powered by Disqus