A Simple Form Field Comparison Validator for Flex

In addition to a Date Range Validator control for a recent project, I also need to compare to user input fields for confirm email address and confirm password. Since I’d just extended the DateValidator, I figured the same approach would work for comparing two controls.

Class: FieldComparisonValidator.as

Disclosure: this was evidently something Adobe Consulting had in their bag of tricks for Flex 2, but namespaces had changes and the code I found burried in a mailing list didn’t work. I made some quick updates to what I saw there, and this works fine for comparing mx:TextInput.

To see how the entire form validation plays out in my forms, check out the previous post How to Validate a Date Range in Flex.

To validator implemntation is:

[html4strict]

[/html4strict]

I’ll be using this thing aplenty, so if it breaks down I’ll be sure to update it. If you have a better validator for this scenario, or an improvement, please let me know.


Categories: GeneralFlexPermalink