案例 ce-0064 · 场景 scenario-pattern-validation

pattern attribute does not validate contenteditable content

操作系统: Windows 11 设备: Desktop or Laptop Any 浏览器: Firefox 120.0 键盘: US 草稿
patternvalidationregexfirefox

此页面尚未翻译

目前显示的是英文原文。欢迎您参与翻译工作。

Phenomenon

The pattern attribute, which allows regex-based validation on form inputs, does not work on contenteditable regions. Content cannot be validated against a pattern.

Reproduction example

  1. Create a contenteditable div with pattern="[0-9]+" (numbers only).
  2. Type non-numeric characters.
  3. Observe whether validation occurs.

Observed behavior

  • In Firefox on Windows, the pattern attribute is ignored on contenteditable.
  • No validation occurs.
  • Invalid content can be entered freely.

Expected behavior

  • The pattern attribute should validate contenteditable content.
  • Invalid content should be rejected or flagged.
  • Or, there should be a standard way to validate content against patterns.

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: Windows 11
Device: Desktop or Laptop Any
Browser: Firefox 120.0
Keyboard: US
Your environment

Use this editable area to reproduce the described case.

Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.