Bug Tracker

Modify

Ticket #3569 (closed bug: wontfix)

Opened 5 years ago

Last modified 4 years ago

[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@…
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by flesler

  • Owner set to joern

comment:2 Changed 4 years ago by joern

  • Status changed from new to closed
  • Resolution set to wontfix

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.