Peter
Member
I have a field that can be filled out by the user or left empty. Is it okay to use the placeholder attribute to describe the meaning of the empty field so that it becomes obvious to the user that leaving it empty is fine?
As an example I have a field where the user can input a "size limit".
Size limit: [___________]
It's probably not obvious that if the user doesn't want a size limit he can just leave the field empty. I could of course add some additional text, above or below, but instead I was thinking that maybe I can use the placeholder attribute to display the meaning of the empty field to the user:
Size limit: [no limit___]
It seems like the placeholder attribute is mostly intended for describing what kind of values can be inputted in the field, which is quite different from what I want to use it for.
It says it should be shown when the field is empty but it doesn't say if it's okay for a browser to show it for non-empty fields. That would be very confusing for my use case. The only thing that makes me believe this is not the intention is the name placeholder.
As an example I have a field where the user can input a "size limit".
Size limit: [___________]
It's probably not obvious that if the user doesn't want a size limit he can just leave the field empty. I could of course add some additional text, above or below, but instead I was thinking that maybe I can use the placeholder attribute to display the meaning of the empty field to the user:
Size limit: [no limit___]
[url=http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-placeholder-attribute]W3[/url] said:The placeholder attribute represents a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. A hint could be a sample value or a brief description of the expected format.
[...]
User agents should present this hint to the user, after having stripped line breaks from it, when the element's value is the empty string, especially if the control is not focused.
It seems like the placeholder attribute is mostly intended for describing what kind of values can be inputted in the field, which is quite different from what I want to use it for.
It says it should be shown when the field is empty but it doesn't say if it's okay for a browser to show it for non-empty fields. That would be very confusing for my use case. The only thing that makes me believe this is not the intention is the name placeholder.