开始日期 与 结束日期的范围选择
两者都不能大于今天,开始日期不能大于结束日期
两者都不能大于今天,开始日期不能大于结束日期
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundGradientColors="[#ffffff, #ffffff]">
- <mx:Script>
- <![CDATA[
- import mx.controls.DateField;
- [Bindable]
- private var today:Date = new Date(new Date().setHours(0,0,0,0));
- [Bindable]
- private var start:Date = today;
- [Bindable]
- private var end:Date = start;
- //=======================================
- //Event Handler
- //=======================================
- /*DateChange*/
- private function onDateChangeHandler(event:Event):void
- {
- //var currentDF:DateField = DateField(event.currentTarget);
- if(startDF.text == "")
- {
- startDF.selectedDate = start;
- }
- else
- {
- start = startDF.selectedDate;
- }
- if(endDF.text == "")
- {
- endDF.selectedDate = this.end;
- }
- else
- {
- this.end = endDF.selectedDate;
- }
- }
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar width="446" dock="true">
- <mx:Label text="开始日期:" />
- <mx:DateField id="startDF" showToday="true" selectedDate="{start}" formatString="YYYY年MM月DD日"
- selectableRange="{{rangeEnd:end}}" change="onDateChangeHandler(event)"/>
- <mx:Label text="结束日期:"/>
- <mx:DateField id="endDF" showToday="true" selectedDate="{end}" formatString="YYYY年MM月DD日"
- selectableRange="{{rangeStart:start,rangeEnd:today}}" change="onDateChangeHandler(event)"/>
- </mx:ApplicationControlBar>
- </mx:Application>