I am trying to find the best way to check one page validation. It contains:
- ship address
- billing address
- and etc.
The class class obviously contains First Name , Last Name , Street1 , Street2 , City , State , Zip , Phone , etc.
Let's say that the user clicks "OK" before entering anything - then you will get a dozen or more verification errors, giving you a large block of red text that looks just ugly.
I would like to check the address as a single object and give an intellectual error - for example, an "incomplete address" or more specific errors, if necessary. But I still want to be able to highlight every single area that has problems. I don’t see an easy way to do this right now, because obviously the Html.ValidationSummary will show each field.
So, I want to show the summary as:
"Your shipping address is incomplete"
and highlight Zip and City red.
I think I would need to execute a fully custom ValidationSummary file and possibly even a fully custom data structure.
Make all validation frameworks easier to make this summary when the summary should display an intelligent summary, and not just every single field error.
Edit: MVC 2 RC now supports model-level errors.
ValidationSummary now supports overloads where only model level errors are displayed. This is useful if you show the validation messages located next to each form field. Previously, these messages will be duplicated in the resume validation. With these new changes, you can have a summary display of a general verification message (for example, "There were errors in the presentation of your form") as well as a list of validation messages that do not apply to a specific field.
Has anyone got a real sample of how to do this?