1 Reply Latest reply on Jan 11, 2007 4:55 PM by dimival

    NumberValidator

    KomputerMan.com Level 1
      Hello all flexers...
      I am using a NumberValidator in one of my forms. This is the call I am using...

      <mx:NumberValidator id="MyIndex_Num" source="{Input_Index_Num}" property="text" domain="int" required="false" invalidCharError="This field must be an integer." />


      This is the method I use to create the control that I want to ensure is an integer.

      <mx:TextInput id="Input_Index_Num" width="150" top="250" left="10" styleName="TextInput" focusIn="anyEvent()" />


      When I process the form I use this code to call my validator.

      private var vResult:ValidationResultEvent;

      private function addTrans():void
      {
      var x:int;

      vResult=MyIndex_Num.validate(); // Make sure the index number is an integer.
      if (vResult.type == ValidationResultEvent.INVALID)
      {
      x = 1;
      }
      }


      The thing is this validator works fine if I take out the required flag from the validator tag. But if I leave the required="false" in the validator the code does not fail if the user enters characters into the Input_Index_Num field in addition to digits.

      I don't want this field to be required but I do want it to fail if the user enters something other than digits into the Input_Index_Num field. Can you see anything wrong with this code because I can't and it is driving me to drink!!!

      Thanks for the help!!!

      Have an Ordinary Day...
      KomputerMan ~|:-)