Fix multiple error labels for HTML5 form-attributed elements#2530
Draft
Fix multiple error labels for HTML5 form-attributed elements#2530
Conversation
Co-authored-by: bytestream <[email protected]>
Co-authored-by: bytestream <[email protected]>
Copilot stopped work on behalf of
bytestream due to an error
February 19, 2026 12:20
Member
|
@copilot try again |
Contributor
Author
Completed! All tasks in the checklist are done:
The PR is ready for review. The fix ensures error labels for form-attributed elements are properly tracked and reused, preventing duplicates on multiple validations. |
Copilot
AI
changed the title
[WIP] Fix multiple error labels in HTML5 validation
Fix multiple error labels for HTML5 form-attributed elements
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan to Fix Form Attribute Multiple Error Labels Bug
errors()function searches only within form element, missing error labels placed outsideerrors()function to include error labels for form-attributed elementsSummary
This PR fixes a bug where input fields linked to a form via the HTML5
formattribute would get multiple error labels when validation was triggered multiple times.Root Cause: The
errors()function insrc/core.jsonly searched for error labels within the form element's DOM tree (errorContext). When inputs are outside the form but linked via theformattribute, their error labels are placed next to the inputs (outside the form), soerrors()couldn't find them. This causedshowLabel()to think no error label existed and create a new one each time validation ran.Solution: Enhanced the
errors()function to also search for error labels associated with elements that have aformattribute pointing to the current form's ID. This ensures that error labels for form-attributed elements are properly tracked and reused.Changes Made
errors()function to include error labels for form-attributed elements--no-sandboxflag for CI environment compatibilityTesting
<issue_title>Linkend input fields via HTML5 form attribute validation mutliple error labels</issue_title>
><issue_description>## Your environment
> * Version of
jquery-validate: 1.22.1> * Version of
jquery: 3.7.1> * Browser name and version: Firefox 147.0.2
> * Browser name and version: Microsoft Edge 145.0.3800.58 (official build) (64-bit)
> * Browser name and version: Google Chrome 145.0.7632.76 (Official Build) (64-bit)
>
> ## Current behavior
>
> When using
inputtags outside theformtag, linked with the HTML form attribute, and adding rules with a custom message, pressing submit multiple times shows multiple error labels.>
> This does not happen when an input tag is inside the form tag
>
> ## Expected behavior
>
> Custom validation messages should appear only once
>
> ## Live demo
>
>
>https://codepen.io/barts2108/pen/YPWojxr?editors=1010
>
> ## Description of the live demo
>
> One table with 2 rows.
>
> 1. First row all three columns are linked using the form attribute. Pressing the Add button in this row multiple times will show that the error label is added multiplt times
> 2. Second row has one input tag moved into the form tag. Pressing the Add button multiple times here shows that the linked input tags get multiple error labels, but the one moved into the form tag will get only 1 error label, no matter how many times you press the Add button</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
>
>
>
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.