Use EmailValidator to validate email cell editor : EmailValidator « Data Model « Flex






Use EmailValidator to validate email cell editor

Use EmailValidator to validate email cell editor
     

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white">
    <mx:Script>
        
        import mx.collections.ArrayCollection;
        import mx.events.DataGridEvent;
        import mx.validators.EmailValidator;
        import mx.controls.TextInput;
        
        [Bindable]
        public var myAC:ArrayCollection = new ArrayCollection([
            {name:"a", email:"a@i.com"},
            {name:"b", email:"b@i.com"}]);
        
        private function onEditEnd(event:DataGridEvent):void
        {
            if(event.dataField == 'email'){
                var fCell:Array=[event.columnIndex,event.rowIndex];
                var newData:String = TextInput(event.currentTarget.itemEditorInstance).text;
                var emailVal:EmailValidator = new EmailValidator();
                var valResult:* = emailVal.validate(newData);
                if(valResult.type == "invalid"){
                   trace("not valid");
                }
            }
        }

      
    </mx:Script>
    <mx:DataGrid id="dg" width="350" height="150" dataProvider="{myAC}" itemEditEnd="onEditEnd(event)" editable="true">
        <mx:columns>
            <mx:DataGridColumn headerText="Name" dataField="name" />
            <mx:DataGridColumn headerText="EMail" dataField="email" />
        </mx:columns>
    </mx:DataGrid>
</mx:Application>

   
    
    
    
    
  








Related examples in the same category

1.Using ActionScript to validate EmailUsing ActionScript to validate Email
2.Email address validationEmail address validation
3.Using a submit button to validate form fieldsUsing a submit button to validate form fields
4.Data source for EmailValidatorData source for EmailValidator
5.Using the EmailValidator classUsing the EmailValidator class
6.Using EmailValidatorUsing EmailValidator
7.Validate Email With ActionScriptValidate Email With ActionScript
8.Use new line character to error messageUse new line character to error message