12
May
07

Quicktip: Flex Form Validation - Sometimes tapping the user on the shoulder just isn’t enough

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));
}

valpop.jpg
If anyone knows of a better way to accomplish this task, please send it my way.

thanks -s


5 Responses to “Quicktip: Flex Form Validation - Sometimes tapping the user on the shoulder just isn’t enough”


  1. 1 Alex C Sep 24th, 2008 at 12:55 pm

    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!

  2. 2 Alex C Sep 24th, 2008 at 1:06 pm

    One followup: How do you detect that a form field’s validation returned an error so you can fire off this function?

  3. 3 Alex C Sep 24th, 2008 at 2:23 pm

    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.

  4. 4 admin Sep 24th, 2008 at 9:48 pm

    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

  1. 1 Pingback on Jul 5th, 2007 at 2:27 pm

Leave a Reply




Vote

flickr