1
Vote

ErrorMessage not working for RequiredIf

description

I have my model with:
[RequiredIfTrue("OtherField", ErrorMessage = "The field {0} cannot be blank")]
[Display(Name = "User Name")]
public string Name { get; set; }
But the server side validation (ModelState) only give to me the default error message "The field User Name is Required.".

Beside in same model I have other fields with Required attribute (native from .Net) and for that fields works well but for all fields with RequiredIf I'm aways get the default message.

How can I fix this?

comments