I have a viewmodel such that, on validation, I want to compare multiple fields. I have a custom attribute that takes the viewmodel and performs the required validation. I am decorating the viewmodel class with the custom attribute [ValidateThisForm]

[AttributeUsage(AttributeTargets.Class)]
public class ValidateThisForm : ValidationAttribute
{
    public override bool IsValid(object value)
    {
        ViewModel _viewModel = value as ViewModel;

        if (_viewModel.TestOne == false && _viewModel.TestTwo == false)
        {
            ErrorMessage = "Form Incomplete: Please correct";
            return false;
        }
        else
        {
            return true;
        }
    }
}

The problem is, I want to perform several "class level" validations. As a result, in my view, I can only display these errors in one place on the form:

<td class = "field-validation-error">@Html.ValidationMessageFor(viewmodel => viewmodel)</td>

Is there a way that I can have multiple "class level" errors being displayed in different locations on the form?

Assuming your class currently looks something like this:

[ValidateThisForm]
public class MyViewModel
{
    public bool TestOne { get; set; }
    public bool TestTwo { get; set; }
}

If you have complex model-level validation you want to perform, where you can't simply annotate a single property, you can hook into the validation pipeline with IValidatableObject like this:

public class MyViewModel : IValidatableObject
{
    public bool TestOne { get; set; }
    public bool TestTwo { get; set; }
    
    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    { 
      if (TestOne == false && TestTwo == false) 
      {
          yield return new ValidationResult("Form Incomplete: Please correct")
      }
    }
}

You can continue to yield return as many validation messages as you'd like. And you can display them all on the client with @Html.ValidationSummary

If you'd like the message to appear alongside a particular control, the ValidationResult constructor takes an overload with the memberNames of the affected properties so you could change the Validate method like this:

if (TestOne == false && TestTwo == false) 
{
    yield return new ValidationResult("Form Incomplete Message", new[] {"TestOne"})
}

Then you can provide the validation message for that particular property with the ValidationMessageFor HTML helper like this:

@Html.ValidationMessageFor(Function(model) model.TestOne )

For further reading, Scott Guthrie wrote about using IValidatableObject as part of his blog post introducing new features in MVC3 and had a follow up post with more detail on class level validation shortly thereafter.