Since Flex 360 I’ve been completely engulfed in a large project in which a large portion of it is in yes, Flex. Flex and I have been getting along pretty well but from time to time we rumble a bit. In the case of form validation flex seems to be perfect in almost every way… except that after the validation happens the only signal to the user that something needs to be done is the hightlight around the control. This is the validation equivalent of a tap on the shoulder to the user.
What i wanted was to show was the rollover popup for the first form element the user had to alter in order to have a valid form immediately upon hitting submit. Unfortunately I couldn’t find any method to raise the popup so I wrote a quick little hack that does the job. Its not perfect, but one of the best things I learned from the flex 360 conference was when Jessie Warden said “sometimes you just throw stuff out there and its hot!”. Essentially, what I think he meant was what you do may not always be the best way, but if it does the trick… go with it.
private function setValidationFocus(formObject:Object):void{
formObject.setFocus();
formObject.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER));
}

If anyone knows of a better way to accomplish this task, please send it my way.
thanks -s



I’ve been searching high-and-low for an elegant solution like this — to actually show the error rather than have the user roll over the field to see it! Wow! Thanks!
One followup: How do you detect that a form field’s validation returned an error so you can fire off this function?
Found a solution to get this working; posted it to my blog: http://devharbor.blogspot.com/2008/09/flex-validator-error-message-issue.html
Not sure why the field property is coming up null on the ValidationResultEvent. I’ve found a workaround.
Hey Alex,
Truth be told I haven’t thought about this in a good long while but I’m glad you found it useful. I’ll be sure to check out your follow-up when i get a chance.
Regards,
Steven