Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 input type=number and the placeholder attribute

Is there any way to use placeholder on <input type=number>?

like image 815
Diogo Cardoso Avatar asked Feb 03 '11 15:02

Diogo Cardoso


2 Answers

I've just checked against the HTML5 spec for input where a type is number and it explicitly says that the placeholder attribute may not be used. I also had errors with http://validator.w3.org when I tried to validate html with an input type of number with a placeholder attribute. Looks like browsers may support this but it's not valid in the HTML5 spec.

like image 187
Jeremy Avatar answered Nov 15 '22 23:11

Jeremy


@zachleat is correct, the placeholder attribute is allowed in the latest HTML5 spec:

HTML 5.1 2nd Edition: forms, number-state-typenumber (see the bookkeeping section)

The following common input element content attributes apply to the element: autocomplete, list, max, min, placeholder, readonly, required, and step content attributes;

like image 26
JacksGT Avatar answered Nov 15 '22 23:11

JacksGT