Example text in field that disappears when you click in it

I’ve seen websites that have example text inside a field that disappears when you click in the field. For example, a phone number field might have the following example: ###-###-####. Can this be done with PHP or do I have to learn javascript?

Thanks!

It’s JavaScript for this one, google for,
javascript prefilled input

You will have may choices.

Clicking the field happens client side and PHP code is executed server side before the html is sent to the browser. Therefore you have to use javascript. Just attach an onclick event handler to the field so that when the field is clicked, the event handler changes the value of the field from the default to null or an empty string.