Try our conversational search powered by Generative AI!

XForms: too many validation summary entries for 1 field



In my xform, we have a field where the user writes his/her email address. We've set this to validate as an email address. The validation works, but when it prints out the "email address didn't pass validation" error message in the validation summary at the top, it prints out the same message 3 times, even though it is just 1 field that hasn't passed validation.

Does anyone know what this is?

Mar 20, 2014 10:36

Can you give us the code from the view where the validation is made?

Mar 20, 2014 16:19


I had exactly the same issue after upgrading one of the sites from Epi 7 to 7.5.

I have used in view


and after upgrade errors were there multiplied by 3 e.g. when there were 5 errors on one form validation summary showed there 15 errors (each of errors repeated 3 times)

As a solution I have created own extension method which filters the error messages:

		public static MvcHtmlString FilteredValidationSummary(this HtmlHelper html, ModelStateDictionary modelState)
			List errors = new List();
			StringBuilder builder = new StringBuilder();

"); builder.AppendLine("
    "); foreach (var state in modelState.Values) { foreach (var error in state.Errors) { if (!errors.Contains(error.ErrorMessage)) { errors.Add(error.ErrorMessage); builder.AppendFormat(@"
  • {0}
  • ", error.ErrorMessage); } } } builder.AppendLine("
"); builder.AppendLine("
"); if (errors.Count > 0) return new MvcHtmlString(builder.ToString()); else return null; }

and just callled that from the view:

Edited, Jul 18, 2014 8:26

I've just run into the same issue and was about to do much the same as yourself Grzegorz, so thanks for saving me some legwork.

Sep 24, 2014 12:29

Just a small update on code snippet :)

public static MvcHtmlString FilteredValidationSummary(this HtmlHelper html, ModelStateDictionary modelState)
    var errors = new List<string>();
    var builder = new StringBuilder();

    builder.AppendLine(@"<div class=""validation-summary-errors"">");
    foreach (var error in modelState.Values.SelectMany(state => state.Errors.Where(error => !errors.Contains(error.ErrorMessage))))
        builder.AppendFormat(@"<li>{0}</li>", error.ErrorMessage);


    return errors.Count > 0 ? new MvcHtmlString(builder.ToString()) : null;
Oct 15, 2014 8:28

This workaround works fine only if you distinguish the particular input fields by ToolTip in the xform definition. If you leave the ToolTip empty then all error messages will be the same, e.g. for required fileds the message is "Vaadittua kenttää ei ole määritetty". So if you have 2 mandatory inputs then the workaround solution above will display only one error message in the validation summary, which is wrong :( So definitely this whole issue should be reported as bug to EPiServer.

Jan 05, 2015 13:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.