17
Dec
07

Setting a minimum and maximum allowable year in the Flex DateField control

The following example shows how you can set a minimum and maximum allowable year in the Flex DateField control by setting the minYear and maxYear properties.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/17/setting-a-minimum-and-maximum-allowable-year-in-the-flex-datefield-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:DateField id="dateField"
            yearNavigationEnabled="true"
            minYear="2000"
            maxYear="2010" />

</mx:Application>

View source is enabled in the following example.


3 Responses to “Setting a minimum and maximum allowable year in the Flex DateField control”


  1. 1 Brett Walker Dec 17th, 2007 at 10:03 am

    Yes, although the DateField component is terribly time-consuming/annoying when trying to choose a year that is more than 100 years back. I think the UI for this component needs to be revisited: holding down the arrow button is not really the optimal interface mechanism for this purpose. Another problem with way-back years and DateField is that DateField completely breaks on any years in the BC era (anything before 0, e.g. negative numbers).

  2. 2 Raul Riera Dec 17th, 2007 at 10:16 am

    Wow, I want to know why would you need a date that old

  3. 3 John Dec 17th, 2007 at 11:54 am

    I wish the time component is more user friendly as has been done on Flex AIR.

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".