How can we enable data annotation validation on client side in MVC?
This can be done in two steps.
Step 1:
In this step we will add necessary Jquery files.
<script src="<%= Url.Content("~/Scripts/jquery-1.5.1.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>
Step -2 :
In this step to call the EnableClientValidation method.
<% Html.EnableClientValidation(); %>
After completing these two steps , you can see the validation message.
Step 1:
In this step we will add necessary Jquery files.
<script src="<%= Url.Content("~/Scripts/jquery-1.5.1.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>
Step -2 :
In this step to call the EnableClientValidation method.
<% Html.EnableClientValidation(); %>
After completing these two steps , you can see the validation message.
nice one :)
ReplyDelete