3 Replies Latest reply on Jun 15, 2006 11:02 AM by ntsiii

    combo box date validation

      As per our requirement, we need to put combo boxess for date input. we are giving the user to input as dd month year format from the given combos. Can you give me idea how to validate the date(feb 31 ..) from the given inputs. If it is textbox, it will be ok. but our need is very particular about, comboboxes.

        • 1. Re: combo box date validation
          Level 7
          A DateValidator can validate against comboboxes as you describe. Here is an
          example. With the following code, try entering an invalid date such as Feb.
          31, and then pressing the Submit button; you will see a red border around the
          Day field, and when you hover over it, you will see text that says, "Enter a
          valid day for the month."

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          <mx:ComboBox id="day" prompt="day" rowCount="31" dataProvider="{days}" />
          <mx:ComboBox id="month" prompt="month" rowCount="12" dataProvider="{months}" />
          <mx:ComboBox id="year" prompt="year" rowCount="20" dataProvider="{years}" />
          <mx:Button label="Submit" id="submit" />

          daySource="{day}" dayProperty="selectedItem"
          monthSource="{month}" monthProperty="selectedItem"
          yearSource="{year}" yearProperty="selectedItem"
          trigger="{submit}" triggerEvent="click"

          <mx:Array id="years" />
          <mx:Array id="days" />
          <mx:Array id="months" />

          private function init():void
          var i:int;
          for (i = 1900; i <= 2006; ++i)
          for (i = 1; i <= 31; ++i)
          for (i = 1; i <= 12; ++i)
          • 2. Re: combo box date validation
            j2eesatish Level 1
            Thanks a lot!
            The code looks fine. It will bbe exactly suited for our requirement. But, i am getting some errors while executing the code. here the given exampel include the line <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">.
            but our application is <mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml" initialize="loadme()">

            Will this exaple will not suite for the macromedia mxml form? i ve change as adobe. but the application is not able to recognize this!. Can you give me some help on this!

            • 3. Re: combo box date validation
              ntsiii Level 3
              You must be running version 1.5.

              There is enfough difference between the tow to make reverse migration very difficult. Using the docs and this example, though, you might be able to see what is needed.

              If you indicate the Flex version you are using in you post, it will save everyong a lot of time.