views:

37

answers:

1

Hello,

I am using ASP.NET MVC2 and to validate the forms i use xVal. It seems like the server side validation works fine, but the client side validation doesnt work or atleast doesn't show up.

The code i use 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 the server side validation works.

Searching on xVal on this side i found this post that looks a bit like the same problem: http://stackoverflow.com/questions/2680153/using-xval-with-fields-containing-periods But no answers here (yet).

Thanks in advance for the help.

+3  A: 

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>()%>
Robert