0
votes

I have a Flex screen (MXML) with two date fields (say, From and To date). Based on the date values, data has to be shown on the DataGrid. Here, I have to restrict the user on choosing the date value. A permitted range has to be set in the date field.

Eg, The default date for both date fields is "Today" The permitted range for From Date is "Today - 7 to Today" The permitted range for To Date is also "Today - 7 to Today"

How can I achieve this? Both by selecting the date picker as well as by entering the date value if the date field is set to editable

1

1 Answers

0
votes

I would simply implement a custom DateValidator for this kind of logic especially that users can also type-in certain dates in invalid or not supported format.

ActionScript (pseudo-code):

public class RangeDateValidator extends DateValidator
{
    [Bindable]
    public var fromDate:String;

    protected override function doValidation(value:Object):Array 
    {
        // create a real date and apply your custom logic
        // based on the fromDate value
    }
}

MXML (pseudo-code):

<d:RangeDateValidator source="{ toDate }" property="text" 
    inputFormat="DD.MM.YYYY" fromDate="{ fromDate.text }" />

Let me know if this is working in your case