Single error message on submit

In this short sample is presented a method how to display a single error message for all validation fields besides the errors that are displayed near each field.

Having this behavior, if you have a long form with a lot of fields and you press the submit button, you'll see a generic error message at the bottom of the page alerting you that some fields didn't pass the validation.

This behavior works only if the validation is trigerred on submit.


Username: A value is required.
Password: A value is required. The minimum number of characters not met.
Confirm Password: A value is required. The values don't match
Comments:
Male/Female: Please select a valid item. Please select an item.
Married: Please specify a value.