ASP.NET MVC 3 introduces a number of attributes which derive from ValidationAttribute (System.ComponentModel.DataAnnotations) having client-side validation support. One such attribute is the Compare attribute using which you can compare properties of a model for eg: ‘Email Address’ and ‘Confirm Email Address’.
Here’s an example of how to use this attribute in your application. Consider a sample Visitor class
As you can see, the Compare attribute makes it extremely simple to compare two properties and also define a validation rule. The user is given instant feedback via the ValidationAttribute, if the email addresses do not match.
Will you give this article a +1 ? Thanks in advance