Ahh, Thx for the reply. I get it now :) But my labels isn't always the previous element before the fields. So I changed it to suit my markup. Like this:
$('form').validate({ errorPlacement: function(error, element) { $('label').each(function() { var field_for = $(this).attr('for'); var field_id = $(element).attr('id'); if (field_for == field_id) { $(this).addClass('error'); } }); } }); Nothing fancy, but it works... Btw, thx for the help.. On Jul 23, 12:17 pm, Jules <jwira...@gmail.com> wrote: > Read errorPlacement on validate docs. > > $(document).ready(function() { > $("form").validate({ > errorPlacement: function(error, element) { > $(element).prev().addClass("error"); > } > }); > }); > > <label>Input:</label><input type="text" id="txtInput" name="txtInput" > class="required" /> > > On Jul 23, 3:03 pm, Rizky <br4inwas...@gmail.com> wrote: > > > > > Hi, > > > I need help with the Validation plugin. I want to disable the > > generated error labels and I need to find a way to add the class > > "error" to existing form labels instead. Currently I don't use it and > > simply want to add highlighting to the existing fields and labels. > > > My forms already contain fields with corresponding labels (using the > > basic "for" - "id" relationship). And all i need to do now is to add > > the class "error" to these labels if the corresponding fields has > > errors. > > > Sorry if this question have been asked before. > > > Thx