Member-only story

Flex Email address validation component

Russell Hammett Jr. (Kritner)
2 min readSep 1, 2018

--

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

<?xml version="1.0" encoding="utf-8"?>
<!--
Created By: Russ Hammett
Create Date: 2012-01-03
Description: Text input that validates an email address.
use "required" to control if the email address
is required.

access the public variable isValidEmail to determine
if validation passed on the email address
Modified By: Russ Hammett
Modify Date: 2012-01-06
Modify Desc: Updated validateEmail function to be public and
update errorString accordingly when validation fails or passes.
-->
<mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml"
maxChars="50"
creationComplete="onCreationCompleted();"
focusOut="validateEmail();" >

<mx:Script>
<![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…

--

--

Russell Hammett Jr. (Kritner)
Russell Hammett Jr. (Kritner)

Written by Russell Hammett Jr. (Kritner)

Just a boring Application Developer/Dad. I enjoy gaming, learning new technologies, reading, and potentially other stuff. That’s about it.

No responses yet