Closed ninzacoder closed 5 years ago
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.
The DepotId field is required.
just by changing the DepotId to Nullable property like the following, the validation started working as expected:
public int? DepotId{get;set;}
I have the following validation not working and cannot resolve why that is the case?
I have also tried the following:
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.