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

by Peter deHaan on December 17, 2007

in DateField

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 comments… read them below or add one }

1 Brett Walker December 17, 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).

Reply

2 Raul Riera December 17, 2007 at 10:16 am

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

Reply

3 John December 17, 2007 at 11:54 am

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

Reply

Leave a Comment

Sorry, this blog is terrible at eating HTML comments.
If you're pasting any HTML/XML/MXML code, you need to convert your < characters to &lt; and your > characters to &gt; .

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree

Previous post:

Next post: