ASP.NET MVC 2: How do I make the Ajax.Form to fire the Client Side Validation with Data Annotation?
- by Methee
Here is the code I have so far:
<% Html.EnableClientValidation(); %>
<% using (Ajax.BeginForm("Address", "Accounts", FormMethod.Post, new AjaxOptions(){}, new { id="dialog-form"} )){ %>
<div>
<label for="address">Address Name:</label>
</div>
<div>
<%= Html.TextBoxFor(m => m.Name)%>
<div>
<%= Html.ValidationMessageFor(m => m.Name)%>
</div>
</div>
<input type="submit" value="OK" />
<% } %>
When I click submit, It does the validation on the server side, I kinda like it to validate on the Client instead of taking a trip to the server right away.