Hi friends,
Step 1 : Add McjDevelopment.Mvc3ValidationGroups.dll in your project.
Step 2 : Add jquery.validate.unobtrusive.validationgroups.js in your project.
Step 3 : Create Customer Model
Step 4 : Update your view to use ‘jquery.validate.unobtrusive.validationgroups.js’ immediately after ‘jquery.validate.unobtrusive.js’ (or ‘jquery.validate.unobtrusive.min.js’)
Step 5 : Update your view to include where you want each groups Validation to appear
and don't forget to add "data-val-valgroup-name" tag at you buttons.
Results : When you click Submit1 button
When you click on Submit2 button
McjDevelopment.Mvc3ValidationGroups.Release.0.3.0.0.zip
Today I am going to demonstrate how to implement validation group in MVC.
For this you have to download one validation group jquery and and one validation group dll
Suppose we have customer model, in which we have Name and Email property. We validate this two property on two different buttons.
Step 1 : Add McjDevelopment.Mvc3ValidationGroups.dll in your project.
Step 2 : Add jquery.validate.unobtrusive.validationgroups.js in your project.
Step 3 : Create Customer Model
public class Customer { [Required] [ValidationGroup("Submit1")] public string Name { get; set; } [Required] [ValidationGroup("Submit2")] public string Email { get; set; } }
Step 4 : Update your view to use ‘jquery.validate.unobtrusive.validationgroups.js’ immediately after ‘jquery.validate.unobtrusive.js’ (or ‘jquery.validate.unobtrusive.min.js’)
Step 5 : Update your view to include where you want each groups Validation to appear
and don't forget to add "data-val-valgroup-name" tag at you buttons.
Results : When you click Submit1 button
When you click on Submit2 button
McjDevelopment.Mvc3ValidationGroups.Release.0.3.0.0.zip
No comments:
Post a Comment