0

I've got a problem using jQuery validation plugin. After form validated and corrected invalid fields the assigned label text disappear. Here's my code:

$('#formID').validate({
   debug: true,
   errorContainer: $('#containerID'),
   errorPlacement: function(error, element) {
      var ctrl = $('#lbl_' + element.attr('name'));
      ctrl.addClass('error');
   },
   rules: {
      fieldname1: "required",
      fieldname2: "required",
      ...
   },
   messages: {
      fieldname1: "...",
      fieldname2: "...",
      ...
   }
}).form();

The code above should add the CSS error class to the invalid element assigned label. But when invalid field have been corrected the assigned label text will be deleted. I don't know why. What I'm doing wrong? Or what is missing? I only want to remove error class if field is valid...

tmieruch
  • 191
  • 4
  • 14
  • I've tried to use success-function like this: success: function(label) { ... }. But label text will be deleted before success-method is fired. – tmieruch Jan 15 '13 at 16:01
  • The error label is being deleted or is it just getting a style of display:none ?, because the display: none is the default behavior – Aldo Utrera Jan 15 '13 at 16:27

0 Answers0