I have a jQuery form that displays a message if the user doesn’t fill in the form properly using this code:
if (errorList.length > 0) {
permitted = false;
//Display error message
$("#" + stepName + " legend").after("<div id=\"errorList\" class=\"error\"><h3>Please correct the following </h3><ul></ul></div>");
for (var j = 0; j < errorList.length; j++) {
if (errorList[j] != undefined)
$("#errorList ul").append("<li>" + errorList[j] + "</li>");
}
}
The problem is that when the user tries to submit the form multiple times with errors, this happens:

How do I solve this problem?
Add a
.emptybefore the iterate..