Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Different markup state for empty/no errors validation summary between server and client implementations #3377

@peterblazejewicz

Description

@peterblazejewicz

I'm not sure why there is a need to render empty list element ('HiddenListItem ') in validation summary tag:

private const string HiddenListItem = @"<li style=""display:none""></li>";

if (!isHtmlSummaryModified)
{
htmlSummary.InnerHtml.AppendEncoded(HiddenListItem);
htmlSummary.InnerHtml.AppendLine();
}

When there is no errors the resulting html is:

<div class="text-danger validation-summary-valid" data-valmsg-summary="true">
<ul>
<li style="display:none"></li>
</ul>
</div>

The client side implementation does not care about elements of the list itself, they are always cleared:
https://github.com/aspnet/jquery-validation-unobtrusive/blob/master/jquery.validate.unobtrusive.js#L58-L70

The reason I noticed this is that screen readers/crawlers see that list, even if empty (empty list just adds noise to markup):

image

It would be better to just not render that empty element on server:

<div class="text-danger validation-summary-valid" data-valmsg-summary="true">
<ul></ul>
</div>

Just a little detail.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions