Using xval validation forms on the client side
I am using ASP.NET MVC2 and I am using xVal for form validation. Server side validation seems to work fine, but client side validation doesn't work, or at least doesn't appear.
The code used looks like this:
<% using (Html.BeginForm()) {%>
div class="label"><label for="EmailAddress">Email Address</label></div>
<div class="field">
<%= Html.TextBox(Prefix + ".EmailAddress")%>
<%= Html.ValidationMessage(Prefix + ".EmailAddress")%>
</div>
<%}%>
<%= Html.ClientSideValidation<Customer>(Prefix)%>
When I remove the prefix it works fine. But when I remove it, only server side validation works.
Searching on xVal on this side I found this post which is a bit similar to the same problem: Using xval with fields containing periods But there are no answers here (yet).
Thanks in advance for your help.
+2
a source to share
1 answer
Solved it with the following code:
<% using (Html.BeginForm("ActionName", "Controller")) {%>
div class="label"><label for="EmailAddress">Email Address</label></div>
<div class="field">
<%= Html.TextBox("EmailAddress")%>
<%= Html.ValidationMessage("EmailAddress")%>
</div>
<%}%>
<%= Html.ClientSideValidation<Customer>()%>
+3
a source to share