Custom Validation Attribute MVC2
I have a custom validation attribute which checks to see if two properties have the same values or not (like password and retype password): [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class EqualToPropertyAttribute : ValidationAttribute { public string CompareProperty { get; set; } public EqualToPropertyAttribute(string compareProperty) { CompareProperty = compareProperty; ErrorMessage = string.Format(Messages.EqualToError, compareProperty); } public override bool IsValid(object value) { if (value == null) { return true; }