How would I go about having multiple textboxes on an MVC 3 form treated as one for the purposes of validation?
It\'s a simple phone number field with one textbox for
You could handle this by putting IValidatableObject on the model class, and implementing the Validate method.
It could look something like this:
public IEnumerable Validate(ValidationContext validationContext)
{
if (String.IsNullOrEmpty(_PhonePart1) || String.IsNullOrEmpty(_PhonePart2)
|| String.IsNullOrEmpty(_PhonePart3))
{
yield return new ValidationResult("You must enter all " +
"three parts of the number.");
}
}