How to show multiple font colors inside the Text Field

khurram picture khurram · Apr 12, 2012 · Viewed 7k times · Source

i want text inside the text field like "your name* "
the color of "your name" should be black and the color of * should be red.
how can i do this??

Please help me.

Answer

Jukka K. Korpela picture Jukka K. Korpela · Apr 12, 2012

You cannot; the value of a text input field is plain text.

Put the explanation, including the requiredness indicator if desired, in a label, not into the field. The you can use markup for the indicator, and color it:

<label for=name>Your name<span class=reqd>*</span>:</label>
<input id=name name=name size=40 required>