Skip to content

docs(HTMLButtonElement): clarify setCustomValidity and reportValidity only affect submit buttons#44322

Open
xonaib wants to merge 2 commits into
mdn:mainfrom
xonaib:docs-htmlbutton-validity-submit-only
Open

docs(HTMLButtonElement): clarify setCustomValidity and reportValidity only affect submit buttons#44322
xonaib wants to merge 2 commits into
mdn:mainfrom
xonaib:docs-htmlbutton-validity-submit-only

Conversation

@xonaib
Copy link
Copy Markdown

@xonaib xonaib commented Jun 1, 2026

Fixes #42234

setCustomValidity() and reportValidity() on HTMLButtonElement only have practical effect for type="submit" buttons. Buttons with type="reset" or type="button" are barred from constraint validation per the HTML spec: their validity state can be set internally but the UI never reflects it, and reportValidity() always returns true.

Changes:

  • Added a [!NOTE] to the setCustomValidity() page explaining the submit-only constraint.
  • Added a [!NOTE] to the reportValidity() page explaining it always returns true for non-submit buttons.
  • Both notes link to the spec definition of "barred from constraint validation"; the setCustomValidity() note also links to willValidate.

Validation:

  • Commit hooks ran successfully: URL checks, changed xrefs, front matter, markdownlint, and Prettier.
  • Checked the local MDN preview server at http://localhost:5042/en-US/docs/Web/API/HTMLButtonElement/setCustomValidity and http://localhost:5042/en-US/docs/Web/API/HTMLButtonElement/reportValidity; both pages loaded and rendered the new note content.

@xonaib xonaib requested a review from a team as a code owner June 1, 2026 11:27
@xonaib xonaib requested review from pepelsbey and removed request for a team June 1, 2026 11:27
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Preview URLs (2 pages)

Flaws (1)

Note! 1 document with no flaws that don't need to be listed. 🎉

Found an unexpected or unresolvable flaw? Please report it here.

URL: /en-US/docs/Web/API/HTMLButtonElement/reportValidity
Title: HTMLButtonElement: reportValidity() method
Flaw count: 1

  • macros:
    • Macro domxref produces link /en-US/docs/Web/API/HTMLElement/invalid_event which is a redirect
External URLs (2)

URL: /en-US/docs/Web/API/HTMLButtonElement/reportValidity
Title: HTMLButtonElement: reportValidity() method


URL: /en-US/docs/Web/API/HTMLButtonElement/setCustomValidity
Title: HTMLButtonElement: setCustomValidity() method

Copy link
Copy Markdown
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thank you for the PR. It makes it clearer, but I would suggest a few improvements:

  1. Align with the pattern used on sibling pages

    The issue itself points to HTMLFieldSetElement.reportValidity() as a model, and HTMLButtonElement.checkValidity() handles the same situation the same way: both pages bake the "always returns true / no effect" behavior directly into the opening description rather than using a [!NOTE] callout.

  2. Stick to the formatting used in the surrounding text: don’t split lines mid-sentences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTMLButtonElement - setCustomValidity(): Specify button type availability

3 participants