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.
Thank you. Lui
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
.
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();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.