This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11048 - Attribute placeholder not allowed on element input at this point. - is Incorrect
Summary: Attribute placeholder not allowed on element input at this point. - is Incorrect
Status: RESOLVED WORKSFORME
Alias: None
Product: HTML Checker
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: Macintosh All
: P2 normal
Target Milestone: ---
Assignee: Michael[tm] Smith
QA Contact: qa-dev tracking
URL: http://www.martinsolution.com/example...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-14 14:34 UTC by Bruce Martin
Modified: 2015-08-23 07:07 UTC (History)
1 user (show)

See Also:


Attachments

Description Bruce Martin 2010-10-14 14:34:52 UTC
In the Element-specific attributes placeholder is listed therefore should not throw an error when validating.

Element-specific attributes for element input:
Global attributes
accept
alt
autocomplete
autofocus
checked
disabled
form
formaction
formenctype
formmethod
formnovalidate
formtarget
height
list
max
maxlength
min
multiple
name
pattern
placeholder
readonly
required
size
src
step
type
value
width
Comment 1 Michael[tm] Smith 2010-11-11 18:13:07 UTC
please provide a test case
Comment 2 Lotte 2011-06-13 14:22:04 UTC
I get the same error.
You can reproduce it with the following link:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.opinirate.com%2Fkoffie&charset=%28detect+automatically%29&doctype=Inline&group=0
Comment 3 Michael[tm] Smith 2011-06-16 10:25:05 UTC
(In reply to comment #2)
> I get the same error.
> You can reproduce it with the following link:
> http://validator.w3.org/check?uri=http%3A%2F%2Fwww.opinirate.com%2Fkoffie&charset=%28detect+automatically%29&doctype=Inline&group=0

You have <input type=hidden placeholder> and <input type=file placeholder> in that document.

The HTML5 spec doesn't permit placeholder ond <input type=hidden> or <input type=file>

Take a look here:

  http://dev.w3.org/html5/spec/the-input-element.html#input-type-attr-summary

Check the row for "placeholder".

The placeholder attribute is only allowed on the input element if the type is one of the following:

text
search
url
tel
email
password
Comment 4 Bruce Martin 2011-06-16 10:51:33 UTC
Here is my example. I am not using a file or a hidden field and still it fails validation due to the placeholder attribute. 

http://www.martinsolution.com/examples/podcast/index.html
Comment 5 Michael[tm] Smith 2011-06-16 10:57:12 UTC
(In reply to comment #4)
> Here is my example. I am not using a file or a hidden field and still it fails
> validation due to the placeholder attribute. 
> 
> http://www.martinsolution.com/examples/podcast/index.html

That document has <input type=time>

The placeholder attribute is only allowed on the input element if the type is one of the following:

text
search
url
tel
email
password

See the "placeholder" row in the table here:

http://dev.w3.org/html5/spec/the-input-element.html#input-type-attr-summary
Comment 6 Lotte 2011-06-16 11:35:51 UTC
Thanks for your reply.

It might be an idea to refine the error displayed.
I must say it is a bit confusing to first get told "Attribute placeholder not allowed on element input at this point." 
and then getting a list "Attributes for element input:"
...
placeholder
...

Thats why it never occurred to me that the input type was actually the problem here.
Comment 7 Michael[tm] Smith 2011-06-16 12:50:07 UTC
(In reply to comment #6)
> It might be an idea to refine the error displayed.
> I must say it is a bit confusing to first get told "Attribute placeholder not
> allowed on element input at this point." 
> and then getting a list "Attributes for element input:"
> ...
> placeholder
> ...

Yeah, agreed. The current message that gets emitted is confusing.

We have had a bug report open for some time that suggests a way to improve it:

  http://bugzilla.validator.nu/show_bug.cgi?id=339#c0

But it has not been implemented in the validator yet. I will try to see if I might be able to get it implemented in the next couple of weeks.

The basic issue is that the "Attributes for element input:" list included in the error message is a chunk of text that's pulled in programatically from a copy of the HTML5 spec. So what we need to do is have the validator copy over only parts of that list (based on the value of the type attribute of the input element it's reporting the error for) instead of the whole list as-is.