0

I'm using parsley (parsleyjs.org) validation but after a field got validated, an empty element remains in the DOM. How can I remove it?

It seems to be a Parsley bug: Parsley should remove the error container if there are no errors anymore.

Screenshot here

Thank you. Lui

UWS
  • 25
  • 6

2 Answers2

0

parsley chooses to keep that <div> around by design, but you can rely on it's class filled being present or not in your CSS. In short, your CSS rules that use .parsley-errors-list should read as .parsley-errors-list.filled.

Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
  • It does not work for me, I've used in CSS the .filled class but the empty div remains there. – UWS Dec 14 '20 at 08:43
  • I would need a jquery script which will remove the .parsley-errors-list when the input is succeeded. It seems otherwise it is remined there. – UWS Dec 14 '20 at 09:49
0

Only CSS was not working for me. This script does what I wanted. Removes the empty .parsley-errors-list elements.

$('#contactForm').parsley().on('field:success', function() { 
    $('ul.parsley-errors-list').not(':has(li)').remove();
});
UWS
  • 25
  • 6