views:

34

answers:

1

I am designing a creation wizard in ASP.NET MVC 1 and instead of posting back each step, I'm using javascript to toggle the display of the different steps divs.

This is a quick sample of the code, just to explain.

<% using (Html.BeginForm())
   {%>
<fieldset>
<legend>Fields</legend>
<div id="wizardStep1">
    <% Html.RenderPartial("CreateStep1", Model); %>
</div>
<div id="wizardStep2">
    <% Html.RenderPartial("CreateStep2", Model); %>
</div>
<div id="wizardStep3">
    <% Html.RenderPartial("CreateStep3", Model); %>
</div>
</fieldset>
<% } %>

I have javascript that just toggles the visibility of the divs, with each partial view containing a different section of the input form (which is pretty large by itself)

My question is, if the form fails validation and I reload the page with the validation errors, is there a way for me to determine which div contains the error? Either in javascript or other?

Failing that, is there a good client-side validation library for MVC 1?

Ideally I'd love to move to MVC2 and the client side validation built into that, but I am required to use MVC1

+1  A: 

xVal is a good client-side validation framework and is flexible, so you might look into that one to see if it will help do what you need.

xVal

Turnkey
Fortunately, I was able to upgrade to the RTM of MVC2, but before that I looked into this answer and this is pretty much the only way to do it. Thanks!
Alastair Pitts