Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display MVC 3 client side validation results in validation summary
    primarykey
    data
    text
    <p>I have a registration form on which I use client side validation (Required, StringLength etc. specified on my view model). The form is currently pretty much how the scaffolder creates it:</p> <pre><code>@using (Html.BeginForm("Index", "Registration")) { @Html.ValidationSummary(true) &lt;fieldset&gt; &lt;legend&gt;Registration details&lt;/legend&gt; @Html.ValidationSummary(false, "Please correct these errors:") @Html.ValidationMessageFor(model =&gt; model.Username) &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.Username) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.Username) &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Register" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } </code></pre> <p>The only difference is that I moved the ValidationMessageFor to the top right beneath the ValidationSummary. </p> <p>What I would like to do is display the client side validation errors in the validation summary. Currently they are just displayed on top of the form but not using the validation summary. How can I display client side validation errors using the validation summary? Is this even possible?</p> <p><strong>Update</strong></p> <p>Darin I have used your code in a new project and this is what it looks like for me when the client side validation kicks in: </p> <p><a href="http://i56.tinypic.com/i3f320.jpg">Client side validation http://i56.tinypic.com/i3f320.jpg</a></p> <p>I expected this to be shown IN the validation summary with the validation summary styles applied. I also submitted the form which then look like this:</p> <p><a href="http://i55.tinypic.com/2hqcowh.jpg">After submit http://i55.tinypic.com/2hqcowh.jpg</a></p> <p>Thanks,</p> <p>b3n</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload