Change form input box label when data is not valid : Form Validator « Components « Flex






Change form input box label when data is not valid

Change form input box label when data is not valid
           

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
  <mx:Script>
    
      import mx.events.ValidationResultEvent;

      private function invalidHandler(event:ValidationResultEvent):void {
        usernameItem.label = "-=Name=-";
      }

      private function validHandler(event:ValidationResultEvent):void {
        usernameItem.label = "Name";
     }

  
  </mx:Script>

  <mx:Form>
    <mx:FormItem id="usernameItem" label="Name">
      <mx:TextInput id="username"/>
    </mx:FormItem>
    <mx:FormItem>
        <mx:Button id="button" label="Submit" />
    </mx:FormItem>
  </mx:Form>

  <mx:Validator id="validator" source="{username}" property="text" invalid="invalidHandler(event)" valid="validHandler(event)" listener="{null}" />

</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using Flex validators with form modelsUsing Flex validators with form models
2.Set up validator for Form input fieldsSet up validator for Form input fields
3.Use Validator to validate data from a formUse Validator to validate data from a form
4.Validator, Model and Form controlsValidator, Model and Form controls
5.Using Validators.validateAll() method to validate a formUsing Validators.validateAll() method to validate a form
6.Validating form control contents data on user entryValidating form control contents data on user entry
7.Validate form data with ActionScriptValidate form data with ActionScript
8.Validating user input for form dataValidating user input for form data
9.Use ActionScript to validate form dataUse ActionScript to validate form data
10.Validate a date entered into a formValidate a date entered into a form
11.Validate an e-mail address to ensure that it is formatted correctlyValidate an e-mail address to ensure that it is formatted correctly