1 Reply Latest reply on Sep 12, 2006 8:22 PM by inlineblue

    NumberValidator broken?


      I have a date (year) field on a form that I would like to validate. It is not a required field. I have defined the following NumberValidator to make sure that only integers are entered into field:

      <mx:NumberValidator id="livedFromV" source="{livedFromYear}" property="text"
      required="false" domain="int" allowNegative="false"
      invalid="Alert.show('Invalid');" valid="Alert.show('Valid');"/>

      Before I added the required="false" property (the default for this property is "true"), the validator was called whenever I just tabbed through the field (ie, when focus was lost and no data was entered.) It correctly highlighted the entry well in red and showed an error indicating the field was required when I moused over the entry well. So far, so good. It also displayed an error if I entered bad data (like a string).

      But since I don't want the field to be a required entry, I added the required="false" property to the validator as the documentation specified. Now the field isn't required, but bad values are not detected. And neither the valid or invalid events are fired when bad data is entered.

      What have I done wrong? Thanks in advance for the help.