Phenomenon
When marking a contenteditable container as required, the browser’s form validation engine does not check its content. Users can submit an empty editor even if it’s logically “mandatory”.
Reproduction Steps
- Create a
<form>. - Add
<div contenteditable="true" required></div>. - Add a submit button.
- Leave the div empty and click submit.
- Observe that the form submits without showing a “Please fill out this field” tooltip.
Expected Behavior
The browser should ideally support native validation for editable regions or provide a focused pseudo-class for validation states.
Solution
Use a hidden input with the required attribute and sync its value, or use the checkValidity() API manually on form submission.