Input Number placeholder Property

Input Number 对象参考手册Input Number Object

Examples

Modify the placeholder text of the number field:

document.getElementById("myNumber").placeholder = "Amount";

Try it Yourself »

Definition and Usage

The placeholder property is used to set or return the value of the placeholder attribute of the number field.

The placeholder attribute provides a hint describing the expected value of the input field.

This hint is displayed when the input field is empty, and disappears when the field gains focus.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the placeholder attribute.

Note:Internet Explorer 9 and earlier IE versions do not support <input> elements with type="number" attribute.


Syntax

Return the placeholder property:

numberObject.placeholder

Set the placeholder property:

numberObject.placeholder=text

Property Values

Value Description
text Describes the hint for the expected value of the number field (a word or a phrase)

Technical Details

Return Value: A string, representing the hint for the expected value of the number field


More Examples

Example

Display the hint of the number field:

var x = document.getElementById("myNumber").placeholder;
xThe output is:
Quantity

Try it Yourself »


Related Pages

HTML reference: HTML <input> placeholder Attribute


Input Number 对象参考手册Input Number Object Other Extensions