Duplicate errors in Validation Summary


I wrote a custom validation for a column in a table. The rule validates all the rows in the column but because the looseFocus event is on each of the column's textboxes i receive back errors for each column. This sends duplicate errors back to my summary group. I propose the following changes to fix this issue.

file attachments


martincjarvis wrote Mar 21, 2012 at 4:18 PM

Am I righ in thinking that your custom validator should only report a single error for each column? If so, the problem is that the validation framework is built around validating fields (not groups) so it will try and fire the validation for each field.

Would the this approach be a better fit?
Create a hidden field to represent the column (with all of the validation entries for that column)(@Html.Hidden("Validation", "", Html.GetValidationAttributesDictionary(Html.ViewData.ModelMetadata, "data-val-required")))
Modify your custom validation method to check that it's being evaluated against the 'Validation' field -if so perform you column based validation - otherwise, trigger the validation for the 'Validation' field

This should mean that for your custom validator only a single error message is displayed, but other row based validation will work.

martincjarvis wrote Mar 21, 2012 at 8:54 PM

I've reconsidered this and I've implemented a fix (will be included in but is currently in the SVN repository.

wrote Mar 21, 2012 at 8:54 PM

wrote Feb 13, 2013 at 9:23 PM

wrote May 16, 2013 at 3:30 AM

wrote May 16, 2013 at 3:30 AM

wrote Jun 14, 2013 at 7:25 AM