If the result of the validate() method call is invalid then display an alert
<?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;
import mx.controls.Alert;
private function runValidators(event:Event):void {
var validationResultEvent:ValidationResultEvent = validator.validate(null, true);
if(validationResultEvent.type == ValidationResultEvent.INVALID) {
Alert.show("Required");
}
}
</mx:Script>
<mx:Form>
<mx:FormItem id="usernameItem" label="Name">
<mx:TextInput id="username"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="button" label="Submit" click="runValidators(event)" />
</mx:FormItem>
</mx:Form>
<mx:Validator id="validator" source="{username}" property="text"/>
</mx:Application>
Related examples in the same category