whatwg / whatwg/html

Allow form validation on <output> element

Open
#6,232 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

addition/proposal needs implementer interest topic: forms
Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

The output element cannot have validation attributes:
https://html.spec.whatwg.org/multipage/form-elements.html#the-output-element

It could be useful to allow constraint validation. Use case:

<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
    <input type="number" id="a" name="a"> +
    <input type="number" id="b" name="b"> =
    <output name="result" for="a b"></output>
    <p>Total cannot be higher than 100</p>
</form>

There is no declarative way to set constraint validation on individual input elements in this case. With constraint validation on the output, authors could set max="100" and use native form validation and css :invalid selectors.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HTML Standard section linked in the issue, focusing on the output element and constraint validation. Define the required behavior for validation attributes, native form validation, and :invalid selectors; done means the standard clearly specifies and supports this use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.