6 Replies Latest reply on Jun 17, 2010 3:43 PM by jerry98225

    how to stop the function if Validation is fail

    jerry98225 Level 1

      Hello guys

         Got an easy question. I am trying to validate the users inputs to see if they enter the values for my textInput. The validator instance is binded to the button click. If the user clicks the button without entering value, the error messages will pop up, if they enter the values then click the button, the application will process the click event handler. My question is when the user clicks the button without the input information, my handler still process the code, and give me runtime error because the textInput is empty. I know I could use conditional statement to prevent this, but I was wondering if there are any ways to stop the handler by USING VALIDATOR class. Thanks for any helps.

       

      code

       

      AS:

       

      protected function insert_clickHandler(event:MouseEvent):void

      {

       

       

      //do something here if the name if not empty.....I thought the validator will stop the application if the validation is fail.....am I wrong?

       

      }

       

      mxml

      <mx:StringValidator id="cityValid" source="{name}"

      property="text" trigger="{add}"

      triggerEvent="click.add"  //only trigger when click on add state.....

      required="true"/>