SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    858
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    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!
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,099
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's JavaScript for this one, google for,
    javascript prefilled input

    You will have may choices.
    What I lack in acuracy I make up for in misteaks

  3. #3
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by busboy View Post
    I've seen websites that have example text inside a field that disappears when you click in the field.
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •