can someone please tell me how to write validation for "first name and last name must not match".
my model code is
public string firstname{get; set;}
public string lastname{get; set;}
Can we use 'compare' attribute to compare these values
can someone please tell me how to write validation for "first name and last name must not match".
my model code is
public string firstname{get; set;}
public string lastname{get; set;}
Can we use 'compare' attribute to compare these values
You can do something like this
[NotEqualTo("lastname")]
public string firstname{ get; set; }
public string lastname{get; set;}
References: THE COMPLETE GUIDE TO VALIDATION IN ASP.NET MVC 3 - PART 2 and StackOverflow Solution
The StackOverflow link has a lot more types of annotations that could be useful. Hope this helps!