How do I Validate Email or Phone requirement in MVC?
Posted
by user54197
on Stack Overflow
See other posts from Stack Overflow
or by user54197
Published on 2010-04-12T18:29:11Z
Indexed on
2010/04/12
18:33 UTC
Read the original article
Hit count: 244
c#
|asp.net-mvc
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;
}
© Stack Overflow or respective owner