jQuery validation plugin: apply one rule on all required fields
<p>I am using jquery validation plugin for validation. I am using one javascript function for many forms so it is difficult to define rules for all fields for many forms.</p>

<p>What is the code if I want to apply a rule "required=true" for all textfields those have a class "required".</p>

<p>I am trying this but it is applying this rule only on first field. Remember I want to show images instead of error text  message when a field in not validated.</p>

<pre><code>$(obj).find("input.required").rules("add", {

 required: true,
 minlength: 2,

 messages: {

  required : "&lt;img id='exclamation' src='images/exclamation.gif' title='This field is required.' /&gt;",
  minlength: "&lt;img id='exclamation' src='images/exclamation.gif' title='At least 2 characters.' /&gt;"

 }
});
</code></pre>
