2 Replies Latest reply on Nov 17, 2009 7:19 AM by PoorOldCoder

    Newbie: Date Validator question on example from live docs.

    PoorOldCoder

      Studying this example below raises questions I can't find easy answers for in the livedocs.

       

      1.) why do we need the model (just a object structure)? In the date validator i notice that we can't put source="{dateInput.tyext}"

      2.0) The model has an id of "alternateDate", changing it makes no difference.

      2.1) Connected to question 2, how does dateValidator use Model since it has no reference to the model.

      3.) Does the code below work when you have more than 1 date input, do you need a seperate date validator and model for each date input field? this creates a circular problem as there seems to be some implicit link between the dateValidator and the Model...confused. this means i have no way to link models to date validators.

       

       

      Taken from http://livedocs.adobe.com/flex/3/html/help.html?content=validators_1.html

          <mx:Model id="alternateDate">
              <dateInfo>
                  <date>{dateInput.text}</date>
              </dateInfo>
          </mx:Model>

          <mx:DateValidator id="stringDateV"
              source="{dateInput}" property="text"
              inputFormat="dd/mm/yyyy"
              allowedFormatChars="*#~/"/>

          <mx:Form>
              <mx:FormItem label="Date of Birth (dd/mm/yyyy)">
                  <mx:TextInput id="dateInput"/>
              </mx:FormItem>
              <mx:FormItem>
                  <mx:Button label="Check Date" click="stringDateV.validate();"/>  
              </mx:FormItem>
          </mx:Form>