I have a drop-down list named CustomerType with the following values
Id Name
1 Student
2 Non-Employed
3 Employed
4 SelfEmployed
and I have one more property in viewmodel public string CompanyAddress{ get; set; }
My goal is to make mandatory for CompanyAddress if dropdownlist matters 3 or 4
I tried the following but got an error Cannon have duplicate RequiredIf
[RequiredIf("customerTypeID", 3, ErrorMessage = "Please enter company address")]
[RequiredIf("customerTypeID", 4, ErrorMessage = "Please enter company address")]
public string CompanyAddress { get; set; }
source
share