title: jQuery validation: display the focused field error message
body: <p><strong>Objective</strong>: I'd like to display the focused field error message in a container.</p>
  
  <p><strong>What I've done so far</strong>:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;&lt;/title&gt;
          &lt;style type="text/css"&gt;
              label.pre {
                  display:inline-block;
                  width:60px;
              }
          &lt;/style&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"
          type="text/javascript"&gt;&lt;/script&gt;
          &lt;script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"
          type="text/javascript"&gt;&lt;/script&gt;
          &lt;script type="text/javascript"&gt;
              $(document).ready(function () {
                  $("form").validate({
                      messages: {
                          name: "Please specify your name.",
                          email: {
                              required: "We need your email address to contact you.",
                              email: "Your email address must be in the format of name@domain.com."
                          },
                          url: "A valid URL, please.",
                          comment: "Please enter your comment."
                      },
                      showErrors: function (errorMap, errorList) {
                          if (errorList.length) {
                              $("span").html(errorList[0].message);
                          }
                      }
                  });
              });
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
  &lt;span&gt;&lt;/span&gt;
          &lt;form action="#"&gt;
              &lt;div&gt;
                  &lt;label class="pre" for="entry_0"&gt;Name *&lt;/label&gt;
                  &lt;input type="text" class="required" name="name" id="entry_0"&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;label class="pre" for="entry_1"&gt;Email *&lt;/label&gt;
                  &lt;input type="text" class="required email" name="email"
                  id="entry_1"&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;label class="pre" for="entry_2"&gt;URL&lt;/label&gt;
                  &lt;input type="text" class="url" name="url" id="entry_2"&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;textarea class="required" name="comment" id="entry_3" rows="7" cols="35"&gt;&lt;/textarea&gt;
              &lt;/div&gt;
              &lt;div&gt;
                  &lt;input type="submit" name="submit" value="Submit"&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Demo</strong>: <a href="http://jsfiddle.net/RainLover/32hje/" rel="nofollow">http://jsfiddle.net/RainLover/32hje/</a></p>
  
  <p><strong>Problems</strong>:</p>
  
  <ol>
  <li>If you click the submit button, the container(span) shows the first
  error message, no matter which field was focused.</li>
  <li>Focusing on fields using the Tab key works well (except on the URL field), but focusing with a mouse doesn't update the span HTML correctly.</li>
  </ol>