3 Replies Latest reply on Jun 3, 2008 10:04 PM by atta707

    date validator

      i cant seem to get the date validator to work..
      given the inputs, the date should be valid but it shows invalid.. where did it go wrong??
        • 1. Re: date validator
          ibolui Level 1
          hi... anyone help?
          • 2. Re: date validator
            atta707 Level 2
            You might want to study the example given in docs of the DataValidator class:

            <?xml version="1.0" encoding="utf-8"?>
            <!-- Simple example to demonstrate the DateValidator. -->
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

            import mx.controls.Alert;

            <mx:Model id="CheckModel">

            <mx:DateValidator source="{dob}" property="text" allowedFormatChars="/"
            trigger="{myButton}" triggerEvent="click"
            valid="Alert.show('Validation Succeeded!');"/>

            <mx:Panel title="DateValidator Example" width="75%" height="75%"
            paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

            <mx:FormItem label="Enter date of birth (mm/dd/yyyy): ">
            <mx:TextInput id="dob" width="100%"/>

            <mx:FormItem >
            <mx:Button id="myButton" label="Validate" />

            • 3. Re: date validator
              atta707 Level 2
              Here you go:

              private function validateDate() : void {
              var d:Object = new Object();
              d.d = 21;
              d.m = 2;
              d.y = 1982;

              //dateV.source = d;
              //dateV.inputFormat = "DD/MM/YYYY";

              dateV.daySource = d;
              dateV.dayProperty = "d";

              dateV.monthSource = d;
              dateV.monthProperty = "m";

              dateV.yearSource = d;
              dateV.yearProperty = "y";

              var vre:ValidationResultEvent = dateV.validate();
              if (vre.results == null) {