user429620
user429620

Reputation:

HTML5 input placeholder that keeps showing (even when typing?)

It is possible to do something like the screenshot below? The input is of type number, and the "px" is automatically added by the input itself (and cannot be changed).

enter image description here

Upvotes: 2

Views: 335

Answers (3)

umert
umert

Reputation: 138

you can get value of input by document.getElementById and then add 'px' to the value. finally you can set that value in input.

Upvotes: 1

It's not a placeholder. Placeholders are only there to indicate to the user what input type is expected.

You could:

  1. Use JS to check user value and add "px" to the string,
  2. Create a small vector image of 'px' and set as the textbox background positioned right.

Upvotes: 2

user1726343
user1726343

Reputation:

You could overlay your input with a span element that has the text px at the right.

Upvotes: 3

Related Questions