/ Published in: ActionScript 3
Showing an input hint in the TextField itself,
hiding it on focus/input,
and showing it again when the input is left empty.
hiding it on focus/input,
and showing it again when the input is left empty.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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; }