articleBody
| -
The page describing the use of input type=‘date’ describes
readonly as if it was a special attribute relevant to
type=‘date’, like the min and max
attributes, rather than as a global attribute applicable to all
form elements.
Also this description includes a paragraph which is repeated
elsewhere on the site:
Note: Because a read-only field cannot have a
value, required does not have any effect on inputs
with the readonly attribute also specified.
But of course read-only fields can and almost
always do have a value, but that value cannot be modified by the
user. This paragraph should read “The required
attribute is not permitted on inputs with the readonly
attribute specified.” The browser should log a diagnostic warning
thatrequired, and all of the other constraint
attributes, is ignored for input elements which have
readonly because the HTML5 standard says “if the
readonly attribute is specified on an input element, the
element is barred from constraint validation.”.
-
Hi @jamesalancobban,
Thanks for posting this. I think you are right — we shouldn’t
mention readonly as a special attribute on certain pages, as it is
global.
To this end, I’ve deleted the mentions on
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
and left the explanation to the readonly section on
the main page:
MDN Web Docs
: The Input (Form Input) element
The HTML input element is used to create interactive controls
for web-based forms in order to accept data from the user; a wide
variety of types of input data and control widgets are available,
depending on the device and user agent.
I added the note about required/readonly there as well.
|