Entity Framework Code First Optional Error Message
[Display(Name = "Mobile")]
public string Mobile { get; set; }
In the above code i want to include something like...
[Required(ErrorMessage="If you don't enter your email we cant send a text confirmation")]
However, i don't want to make th开发者_如何学Pythone field required. Just if a user doesn't enter anything they get a message saying this. Is this possible?
Thanks
You must write your own UI control to support this type of hint. It has nothing to do with common data annotations for validation and because of that you cannot use Required
.
精彩评论