title: How can we specify rules for jQuery validation plugin by class?
body: <p>The <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow noreferrer">jQuery Validation plugin</a> works great and is very easy to use:</p>
  <pre><code>$(&quot;.selector&quot;).validate({
  })
  </code></pre>
  <p>Just by setting CSS classes like &quot;required email&quot;, the default message will be displayed.</p>
  <p>However, I need to customize the messages. The documentation says you can specify rules using a key-value pair for elements and their corresponding messages:</p>
  <pre><code>$(&quot;.selector&quot;).validate({
     rules: {
       name: &quot;required&quot;,
       email: {
         required: true,
         email: true
       }
     },
     messages: {
       name: &quot;Please specify your name&quot;,
       email: {
         required: &quot;We need your email address to contact you&quot;,
         email: &quot;Your email address must be in the format of name@example.com&quot;
       }
     }
  })
  </code></pre>
  <p>But, it is not practical to specify a rule for every form element, especially server-generated controls in ASP.NET. Is it possible to specify rules that would apply to ALL elements? Or can I use a class selector somehow?</p>
  <p>I tried the following, but it didn't work:</p>
  <pre><code>$(&quot;#frmMyForm&quot;).validate
  ({
      rules:
      {
          $(&quot;.required email&quot;):
          {
              required: true,
              email: true
          }
      },
      messages:
      {
          $(&quot;.required email&quot;):
          {
              required: &quot;Please enter your email address&quot;,
              email: &quot;Your email address must be in the format of name@example.com&quot;
          }
      }
  });
  </code></pre>
  <p>That seemed to have a syntax error - the plugin didn't do anything. Then I tried:</p>
  <pre><code>$(&quot;#frmMyForm&quot;).validate
  ({
      rules:
      {
          &quot;.required email&quot;:
          {
              required: true,
              email: true
          }
      },
      messages:
      {
          &quot;.required email&quot;:
          {
              required: &quot;Please enter your email address&quot;,
              email: &quot;Your email address must be in the format of name@example.com&quot;
          }
      }
  });
  </code></pre>
  <p>This didn't have any syntax error - the plugin worked, but it ignored the rules/custom messages. Has anyone here used jQuery Validation plugin? If so, how did you apply rules/custom messages to multiple elements?</p>