This project is read-only.

Installing and Using MVC3 Validation Groups

  1. Download the latest release.  (Get the latest Example Site as well to see a preconfigured MVC3 Website and example integration)
  2. Add a reference to ‘McjDevelopment.Mvc3ValidationGroups.dll’ to your MVC3 project
    image
  3. Copy ‘jquery.validate.unobtrusive.validationgroups.js’ to your ‘scripts’ folder
    image
  4. Decorate your view models with the [ValidatorGroup] attribute specifying the validation groups that that field belongs to (space delimited)
    image
  5. Update your view to use ‘jquery.validate.unobtrusive.validationgroups.js’ immediately after ‘jquery.validate.unobtrusive.js’ (or ‘jquery.validate.unobtrusive.min.js’)
    image
  6. Update your view to include where you want each groups Validation Summary to appear
    image
  7. Amend your ‘Action’ buttons and links to include ‘data-val-valgroup-name’ attribute and specify which validation groups should be triggered by the user clicking on that element
    image
  8. Amend you’re controller to check the appropriate validation groups when called.  (this implementation shows a common action being called with uses the clicked button name to select the validation group, an alternative is to us JS to dynamically alter the form’s action location)
    image
  9. Test validation groups!
    image

Last edited Jan 17, 2012 at 8:25 PM by martincjarvis, version 2

Comments

isseyprada Jun 27, 2012 at 7:59 AM 
How do we validate against DropDownList rather than just against Text? I can't get this to work.

martincjarvis Mar 21, 2012 at 5:29 PM 
The html is the same as the "standard" MVC3 validation summary, with the addition or a data-val-valgroup-name attribute including the Validation Groups that the summary will display messages for.

jaredmahan Mar 14, 2012 at 5:29 PM 
It would be great if you could show us the html generated by @Html.ValidationSummary()