Hopefully this help. -- html
<!-- notice the name field is required by validate plug in to uniquely identify the element --> <input id="field1" name="field1" type="text" class="required" /> <!-- Use attribute "for" with the relevant element. --> <label for="field1" style="display:none">Error text for field1</label> -- script var options = { errorPlacement: function(error, element) { $("label[for='" + element[0].id + "']").addClass (this.errorClass).show(); } }; $("form").validate(options); On Jul 31, 2:11 am, Rudi Cheow <rudich...@gmail.com> wrote: > Hi all, > > Please see this code: > > <form id="myform"> > <input id="field1" type="text" class="required" /> > <div id="field1error">Error1</div> > <input id="field2" type="text" class="required" /> > <div id="field2error">Error2</div> > </form> > > The above is a simplified version of my code, but it shows enough. The > two DIVs are set to "display:none". > > How do I invoke the validate plugin in such a way that it shows the > appropriate DIV when validation fails on the relevant field? > > I have been pulling my hair out over this, and the fact that this is > my first serious foray into jQuery territory doesn't help. > > Any assistance appreciated. > > Thanks.