title: asp.net mvc 3 jquery adding validation message manually
body: <p>I've been search for quite a while and haven't been able to find an answer to this.</p>
  
  <p>I am using asp.net MVC 3 with unobtrusive validation.  My model is bound with data annotations for simple validation (required fields, regex, etc..).  However, I have more complex validation that occurs on the server.  I'm doing an ajax post which returns me validation add'l messages that come from my domain model.  All I want to do is put those validation messages on the form in the place of the existing ones.  I don't want to use partial views since all I've really got are messages coming back and there isn't a need to refresh the whole view.  Also, I'm not adding new rules or new inputs to the form so $.validator.unobtrusive.parse won't work.  These are just messages I want to put on the form.  The $.post call returns a list of message with which field is/was affected and the validation message.</p>
  
  <p>Here's kind of what I'm looking to do</p>
  
  <pre><code> $.post(url, { someData}, function (data) {
           for (message in data.Messages) {
               $("#form").validate().addMessage(message.Field, message.Text);
           }
      });
  </code></pre>
  
  <p>Thanks for your help</p>
  
  <p>Per request, here's a sample of the returning JSON, it's fairly simple.  </p>
  
  <pre><code>{"id":0,"messages":["Level":0,"Message":"Style is required","Name":"Style"}],"operationResult":false}
  </code></pre>
  
  <p>messages is a list of objects that contain the severity level, the property the error belonged to and the error message.  I would use the name in the messages object to match where it want on the form.</p>