ASP.NET MVC 2: How do I make the Ajax.Form to fire the Client Side Validation with Data Annotation?
Posted
by Methee
on Stack Overflow
See other posts from Stack Overflow
or by Methee
Published on 2010-03-07T18:46:37Z
Indexed on
2010/03/31
2:43 UTC
Read the original article
Hit count: 550
ASP.NET
|asp.net-mvc-2
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.
© Stack Overflow or respective owner