Is it okay to use the placeholder attribute to describe the default value?

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___]

[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.
 
It has nothing to do with the browser. Its meant for people who are the coders or admin. It also means that any point in time, you can change or add a value to the placeholder. Think of it more as a book mark so you remember where you stopped reading in the book.
Not sure if this is what you are after as your post is pretty vague
 

Peter

Member
I don't think we are talking about the same thing. I'm talking about the placeholder attribute in HTML5 that you can put on text fields. Usually the placeholder text is shown in lighter color when the field is empty.

<input type="text" placeholder="no limit">

To clarify my original question:
  • The placeholder is intended for describing or giving example of what kind of value that should be put in the field.
  • I want to use it for describing the meaning of leaving the field empty.
So I want to use it in a way that's not intended, but I don't know if there is any harm in doing so.
 

aandreyy96

New member
I belive it's ok to say the default value in placeholder.
You can even specify that no limit is the default value.
placeholder="no limit (default)" or "leave this blank for no limit".
 
To answer your question. Not really.
1, is there for the customer end?
2, is this for the coders end?

The placeholder is what I had said. Example
Code:
<form action="demo_form.asp">
  <input type="text" name="fname" placeholder="First name"><br>
  <input type="text" name="lname" placeholder="Last name"><br>
  <input type="submit" value="Submit">
</form>

What they are saying is, use placeholder if you have not assigned a value to call. Lets say for an example, placeholder would be used if you have no user field in your database yet or where the value you want to call is placed.

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format).

The short hint is displayed in the input field before the user enters a value.

In other words, its for future use

Note: The placeholder attribute works with the following input types: text, search, url, tel, email, and password.
 

Peter

Member
aandreyy96 said:
You can even specify that no limit is the default value.
placeholder="no limit (default)" or "leave this blank for no limit".

Good idea! If I word it like that it's more like a description of the value as it's supposed to be.