/////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?xml version="1.0"?>
<!-- Simple example to demonstrate the Validator class. -->
<mx:Script>
<![CDATA[
// Import necessary classes.
import mx.controls.Alert;
import mx.events.ValidationResultEvent;
// Event listener for the valid and invalid events.
private function handleValid(eventObj:ValidationResultEvent):void {
if(eventObj.type==ValidationResultEvent.VALID)
// Enable Submit button.
submitButton.enabled = true;
else
submitButton.enabled = false;
}
// Submit form is everything is valid.
private function submitForm():void {
Alert.show("Form Submitted!");
}
]]>
</mx:Script>
<!-- The Validator class defines the required property and the validator events
used by all validator subclasses. -->
<mx:Validator id="reqValid" required="true"
source="{fname}" property="text"
valid="handleValid(event)" invalid="handleValid(event)"/>
<mx:Panel title="Validator Example" width="100%" height="100%"
paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5">
<mx:Form>
<mx:Text width="100%" color="blue"
text="Enter a value in the Name field before you can submit. The E-mail field is optional."/>
<mx:FormItem label="Name: " required="true">
<mx:TextInput id="fname" width="100%"/>
</mx:FormItem>
<mx:FormItem label="E-mail address: " required="false">
<mx:TextInput id="email" width="100%"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="submitButton" enabled="false"
label="Submit" click="submitForm();"/>
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
YM : [EMAIL PROTECTED]
Blog : gunadiw.blogsome.com
From: Kenneth Sutherland <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, March 15, 2007 6:34:23 PM
Subject: [flexcoders] validation
I know Ive seen this done somewhere but just cant seem to find it on livedocs or in the history of flexcoders!
Anyway I want to validate a textbox / combobox, but I only want the validation to validate after the user has tabbed out of the box or pressed enter. At the moment it validates after each keypress.
So if the user has a box and has to type Europe then I dont want the validator to say error while they type E then Eu and so on ..
Cheers
Kenneth Sutherland
![]()
Visit our Web site at www.inps.co. uk
The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of In Practice Systems Limited or any of its affiliates. If you are not the intended recipient please contact is.helpdesk@ inps.co.uk

