I have this viewmodel:
public class VM
{
[Required]
public int Int1 { get; set; }
[Required]
public int Int2 { get; set; }
}
In the view, these two ints are chosen via dropdowns. I would like the unobtrusive validation to fail if the same value is selected from both dropdowns (e.g. assume Int1
and Int2
can take values ranging 1-10 and the user chooses 9
for both, validation should fail). I am looking to achieve this with data annotations instead of writing Javascript in the frontend.
I can't find a built-in validation attribute, I found [Compare(string otherProperty)]
but I am essentially looking for the negation of Compare
.