I have the following validation not working and cannot resolve why that is the case?
[Display(Name = "Bus")]
[RequiredIf("SelectedWidgetText == 'Referral'", ErrorMessage = "Please select a Vehicle.")]
public int DepotId{ get; set; }
public string SelectedWidgetText { get; set; }
I have also tried the following:
[Display(Name = "Bus")]
[AssertThat("SelectedWidgetText == 'Referral'", ErrorMessage = "Please select a Vehicle.")]
public int DepotId{ get; set; }
on the server side, when the modelstate.isvalid method is hit, it returns false and the error message thrown is The DepotId field is required.