I don't know if this the best way but it worked for a registration
form I built. Items are validated at valueCommit and when the user
clicks submit.
// Function to validate data and submit it to the server.
private function validateAndSubmit():void {
// Validate the required fields.
errormessage = '';
errormessage += collectValidations(v_playerfirstname);
errormessage += collectValidations(v_playerlastname);
errormessage += collectValidations(v_playerdob);
errormessage += collectValidations(v_parent1firstname);
errormessage += collectValidations(v_parent1lastname);
errormessage += collectValidations(v_parent2firstname);
errormessage += collectValidations(v_parent2lastname);
errormessage += collectValidations(v_parent1phone1);
errormessage += collectValidations(v_parent2phone1);
if (errormessage) {
Alert.show('Please correct the below:\n' +
errormessage, 'FILL Pre-Registration')
return;
}
// Submit data to server.
submitURL();
}
public function collectValidations
(v:mx.validators.Validator):String {
vResult = v.validate();
if (vResult.type==ValidationResultEvent.INVALID) {
return v.source.id + ' ' + vResult.message + '\n';
}
return '';
}
<mx:DateValidator id="v_playerdob" source="{playerdob}"
required="true" property="text"/>
<mx:StringValidator id="v_playerfirstname"
source="{playerfirstname}" property="text" />
<mx:StringValidator id="v_playerlastname" source="{playerlastname}"
property="text" />
<mx:StringValidator id="v_parent1firstname"
source="{parent1firstname}" property="text" />
<mx:StringValidator id="v_parent1lastname"
source="{parent1lastname}" property="text" />
<mx:StringValidator id="v_parent2firstname"
source="{parent2firstname}" property="text" />
<mx:StringValidator id="v_parent2lastname"
source="{parent2lastname}" property="text" />
<mx:EmailValidator id="v_parent1email" source="{parent1email}"
property="text"/>
<mx:EmailValidator id="v_parent2email" source="{parent2email}"
property="text"/>
<mx:StringValidator id="v_parent1phone1" source="{parent1phone1}"
required="true" property="text"/>
<mx:StringValidator id="v_parent2phone1" source="{parent2phone1}"
required="true" property="text"/>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/