How can I watermark a DateField control in Flex 4?

做~自己de王妃 提交于 2019-12-12 04:35:13

问题


I would like to know how to make a DateField control with a watermark. I want to set the prompt/watermark text from MXML like this one:

<mx:DateField id="id_date" propmt="Select date" />

回答1:


Use this

<mx:DateField id="df" text="Select Date"  focusIn="df.text=''" />

OR Refer This Blog for custom datefield component
WaterMarkDateField




回答2:


Its Quite Simple by using the creation complete handler

<mx:DateField id="sample" creationComplete="sample_creationCompleteHandler(event)"/>

set the sample text like this

protected function sample_creationCompleteHandler(event:FlexEvent):void
{
    // TODO Auto-generated method stub
    sample.text = "Select Date";
}

Try this..




回答3:


I have done like following way. Don't know it's correct way or not. But, it's working for me.

<mx:DateField id="dateIdentify" editable="true" selectedDate="new Date()" formatString="MM-DD-YYYY" color="#505050" focusOut="if(dateIdentify.text == ''){dateIdentify.text='MM-DD-YYYY'}" focusIn="if(dateIdentify.text == '' || dateIdentify.text == 'MM-DD-YYYY'){dateIdentify.text='';}" text="MM-DD-YYYY"/>

Hope it helps someone.



来源:https://stackoverflow.com/questions/8005602/how-can-i-watermark-a-datefield-control-in-flex-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!