Return to Snippet

Revision: 36895
at January 10, 2011 22:01 by shuchii


Updated Code
var hint:String = "dd-mm-yyyy";
txtDate.text = hint;

txtDate.addEventListener(FocusEvent.FOCUS_IN, focusIn);
txtDate.addEventListener(FocusEvent.FOCUS_OUT, focusOut);

private function focusIn(evt:FocusEvent):void
{
	if (evt.target.text == hint)	txtDate.text = "";
}

private function focusOut(evt:FocusEvent):void
{
	if (evt.target.text == "")	txtDate.text = hint;

}

Revision: 36894
at November 29, 2010 22:32 by shuchii


Initial Code
var hint:String = "dd-mm-yyyy";
txt_date.text = hint;

txt_date.addEventListener(FocusEvent.FOCUS_IN, focus_in);
txt_date.addEventListener(FocusEvent.FOCUS_OUT, focus_out);

private function focus_in(evt:FocusEvent):void
{
	if (evt.target.text == hint)	txt_date.text = "";
}

private function focus_out(evt:FocusEvent):void
{
	if (evt.target.text == "")	txt_date.text = hint;

}

Initial URL


Initial Description
Showing an input hint in the TextField itself,
hiding it on focus/input,
and showing it again when the input is left empty.

Initial Title
Input Textfield hint

Initial Tags


Initial Language
ActionScript 3