Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset text field 1

Status
Not open for further replies.

TigerGirl7

Programmer
Apr 8, 2003
152
US
Hello,

I have a text field that says "enter your email here". Is it possible to have the text disappear when the user clicks in the field?

Thanks!
 
Code:
my_input_text.onSetFocus = function(){
    my_input_text.text = "";
};


Regards,

cubalibre2.gif
 
Okay, oldnewbie,

I'm having the same trouble. I'm new to FLASH, so where do you put this script? When I try to assign it to the text box in question, it says 'current selections cannot have actionscript applied to it'

What do I do???
 
This script should be on the first frame of your movie. It defines a function, which should execute when your input textfield gets focus.
You should replace my_input_text by the instance name you gave your textfield. If you already have some text in the textfield to start with, then clicking in the textfield (giving it focus), should normally clear the text that was there, ready for the user to input his text.

Regards,

cubalibre2.gif
 
Greetings,

You can take it a step further with the Flash MX onKillFocus function. This function will cause the text field to return to its original state when the user clicks anywhere out of the bounds of the text field. The script below demonstrates:

field1.onSetFocus = function() {
if (field1.text == "enter your email here") {
field1.text = "";
}
};
field1.onkillfocus = function() {
if (field1.text == "") {
field1.text = "enter your email here";
}
};

If anyone needs an FLA concerning this issue, you may reach me at admin@thedarkcontent.com

Sincerely,
Jamie Michels
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top