次の値を持つ CustomerType という名前のドロップダウンリストがあります
Id Name
1 Student
2 Non-Employed
3 Employed
4 SelfEmployed
そして、私は私の中にもう1つの財産を持っていますviewmodel
public string CompanyAddress{ get; set; }
私の目標は、ドロップダウンリストに値がある場合、CompanyAddress を必須にすることです3 or 4
私は以下を試しましたが、エラーが発生します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; }