1 Reply Latest reply on Aug 27, 2006 7:26 PM by Rendl

    Validation of a group of controls

    Rendl
      Hey all, I am a complete Flex noob. I am playing around with a somewhat basic app which presents 5 combobox controls as part of a form. Before the user can submit the form I want to validate that the user has entered data for each combobox. The default value for each combobox is "-" which obviously will fail a NumberValidator check. However with the colde below, as soon as a user enters valid data for any one of the combobox's, the form is valid and the submit button enabled. Is there a way to group the validation, such that a valid result is only return when all comboboxs have valid data?

      private function handleValid(eventObj:ValidationResultEvent):void {

      if(eventObj.type==ValidationResultEvent.VALID)
      // Enable Submit button.
      buttonSubmit.enabled = true;
      else
      buttonSubmit.enabled = false;

      }
      <mx:NumberValidator id="reqCommit" required="true"
      source="{comboCommit}" property="text" domain="int"
      valid="handleValid(event)" invalid="handleValid(event)"/>

      <mx:NumberValidator id="reqTrust" required="true"
      source="{comboTrust}" property="text" domain="int"
      valid="handleValid(event)" invalid="handleValid(event)"/>

      <mx:NumberValidator id="reqGossip" required="true"
      source="{comboGossip}" property="text" domain="int"
      valid="handleValid(event)" invalid="handleValid(event)"/>

      <mx:NumberValidator id="reqRRR" required="true"
      source="{comboRRR}" property="text" domain="int"
      valid="handleValid(event)" invalid="handleValid(event)"/>

      <mx:NumberValidator id="reqTeamHealth" required="true"
      source="{comboTeamHealth}" property="text" domain="int"
      valid="handleValid(event)" invalid="handleValid(event)"/>