Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3569 closed bug (wontfix)

[validate] Validation error is not removed if placeholder is not within the validated <form>

Reported by: noahsatellite Owned by: joern
Priority: minor Milestone: 1.3
Component: plugin Version: 1.2.6
Keywords: validate Cc: noah.blumenthal@…
Blocked by: Blocking:

Description

If the errorPlacement hook is used to add errors to DOM elements outside the form being validated, the error is added when invalid but never removed when valid. Multiple of the same error can be visible at once because the error is never removed before re-validation begins.

take for example this simple form:

<ul id="clientvalidation"></ul> <form id="myForm"> Name: <input type="textbox" id="Name" /> <input type="submit" value="submit" /> </form>

with this validation: $("#myForm").validate({ errorElement: "li", errorPlacement: function(error, element){

error.appendTo($("#clientvalidation")); },

rules: {

Name: {required: true} }

messages: {

Name: {required: "Name is required"} }

});

If you press the submit button multiple times you'll see the error message appear multiple times.

Change History (2)

comment:1 Changed 11 years ago by flesler

Owner: set to joern

comment:2 Changed 11 years ago by joern

Resolution: wontfix
Status: newclosed

Is there an actual reason to place that element outside the form? The form element itself isn't a visual element at all, so making the form a parent element of that ul shouldn't be a problem at all.

Note: See TracTickets for help on using tickets.