8 Replies Latest reply on Aug 8, 2007 5:00 PM by dimival

    Regular Expression Validator Problem

    LordPathogen
      Hi,
      I have a text area that I want to use a regular expression validator on to verify that one or more 9 char alphanumeric serial numbers were entered.
      <mx:RegExpValidator
      source="{entryField}"
      property="text"
      flags="gi"
      expression="{/[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0- 9][a-zA-Z0-9][a-zA-Z0-9]( |,|\\n|\\r|\\t)/}"
      valid="handleResult(event)"
      invalid="handleResult(event)"
      trigger="{entryField}"
      triggerEvent="textInput"
      />

      //for testing
      private function handleResult(eventObj:ValidationResultEvent):void {
      if (eventObj.type == ValidationResultEvent.VALID)
      {
      entryField.setStyle("borderColor", "green");
      entryField.setStyle("borderThickness", "2");
      }
      else
      {
      entryField.setStyle("borderColor", "red");
      entryField.setStyle("borderThickness", "2");
      }
      }

      The problem is the handler function always comes back invalid, even when it should be valid, such as: 123456789 a12345678 lk231jkop

      Can anyone advise where I might be going wrong? Thanks!