A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Input Text Box - Placeholder Text

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Posts
    103

    Input Text Box - Placeholder Text

    I have a simple input box where people can type a message in it and send it off in an email. However, I want people to know what the box is for and that you can type in it. A simple "Type your message here" line would do the trick, but if I have that text pre-typed into the box, the user has to highlight it and delete it before they start typing. How to I make it so that as soon as the user clicks the text box, the placeholder text disappears? I'd really appreciate any help... thanks!

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    you can add a listener to the textField and when it has focus you can set the text to = "";

    I would search for onSetFOcus()

    or Selection.onSetFocus();

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Location
    Glasgow, Scotland
    Posts
    18
    Yup, try something like this:

    Code:
    var initialText:String = "Type your name here.";
    myTF.text = initialText;
    
    myTF.onSetFocus = function():Void {
    	if( myTF.text == initialText ) {
    		myTF.text = "";
    	}
    }
    That way, you can prevent the TextField's contents from resetting every time the TextField is clicked. I'd imagine you only want to remove the initial text once, because then the user knows what's going on.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center