DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Thomas has posted 33 posts at DZone. View Full User Profile

Reset Form Validation Warnings In Flex

01.25.2011
| 4858 views |
  • submit to reddit
        Validators declaration: 
<mx:Array id="validators">
  <mx:StringValidator source="{numberEditor}" property="text" required="true" minLength="3" />
  <mx:StringValidator source="{nameEditor}" property="text" required="true" />
</mx:Array>
AS3 code: 
public function resetForm():void {
  formObject = new formObject(); // the object the form editors (TextInput / ComboBox / etc...) are binded to
  callLater(resetValidationWarnings);
}

private function resetValidationWarnings():void {
  for each (var validator:Validator in validators) {
    UIComponent(validator.source).errorString = "";
  }
}