In MVC I am using [Required(ErrorMessage=””)] to validate my text. How do I utilize a validation for an “Email or Phone Contact” textboxes in my model? I now have the validation in my controller, which I would like to have in the model.
CONTROLLER…
if (insuredInfo.InsuredHPhone == null && insuredInfo.InsuredWPhone == null)
{
ModelState.AddModelError("InsuredHPhone", "Contact Number Required");
isRequired = true;
}
There is a video tutorial on the official MVC website which might be worth watching:
http://www.asp.net/learn/mvc-videos/video-10082.aspx