Determining which form input failed validation?
Posted
by Alastair Pitts
on Stack Overflow
See other posts from Stack Overflow
or by Alastair Pitts
Published on 2010-03-10T23:33:07Z
Indexed on
2010/03/14
20:15 UTC
Read the original article
Hit count: 403
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
© Stack Overflow or respective owner