Flex Email address validation component
I was attempting to find a decent email validation component for flex - one with validators built in and all the bells and whistles. I wasn't able to find one at a quick glance, so I put this guy together, and it seems to actually be working so far :O
<![CDATA[ import mx.events.ValidationResultEvent; private var _isValidEmail:Boolean = true; public function set isValidEmail(value:Boolean):void { _isValidEmail = value; } [Bindable] public function get isValidEmail():Boolean { return _isValidEmail; } [Bindable] public var required:Boolean = false; /** * On Creation Completed * */ private function onCreationCompleted():void { if (required) { emailValidator.enabled = true; } else { emailValidator.enabled = false; } } /** * Validate Email * */ public function validateEmail():void { var vldEmail:ValidationResultEvent; if (this.length > 0) { emailValidator.enabled = true; vldEmail = emailValidator.validate(this.text); if (vldEmail.type == ValidationResultEvent.VALID) { isValidEmail = true; this.errorString = ''; } else { isValidEmail = false; this.errorString = vldEmail.message; } } else { emailValidator.enabled = false; if (required) { emailValidator.enabled = true; vldEmail = emailValidator.validate(this.text); isValidEmail = false; this.errorString = vldEmail.message; } else { isValidEmail = true; this.errorString = ''; } } } ]]>
Thanks http://www.bloggersentral.com/2009/04/how-to-show-code-in-blog-post.html#free for teaching me how to paste code (and making it look pretty) in blogger..













