如何在Flex 4中为DateField控件添加水印?

时间:2022-10-04 19:18:35

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:

我想知道如何使用水印制作DateField控件。我想设置MXML中的提示/水印文本,如下所示:

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

3 个解决方案

#1


1  

Use this

用这个

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

OR Refer This Blog for custom datefield component
WaterMarkDateField

或参考此博客以获取自定义日期字段组件WaterMarkDateField

#2


0  

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


0  

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.

希望它可以帮到某人。

#1


1  

Use this

用这个

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

OR Refer This Blog for custom datefield component
WaterMarkDateField

或参考此博客以获取自定义日期字段组件WaterMarkDateField

#2


0  

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


0  

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.

希望它可以帮到某人。