36 lines
990 B
ActionScript
36 lines
990 B
ActionScript
package com.mycustom.components
|
|
{
|
|
import mx.controls.TextInput;
|
|
import mx.events.ValidationResultEvent;
|
|
import mx.validators.EmailValidator;
|
|
import flash.events.Event;
|
|
import mx.validators.ValidationResult;
|
|
|
|
public class TextInputEmail extends TextInput
|
|
{
|
|
private var emailValidator:EmailValidator = new EmailValidator();
|
|
private var validator:ValidationResultEvent;
|
|
|
|
public function TextInputEmail()
|
|
{
|
|
super();
|
|
this.emailValidator.source = this;
|
|
this.emailValidator.property = "text";
|
|
this.addEventListener("enter", this.validate);
|
|
|
|
}
|
|
|
|
private function validate(event:Event):void
|
|
{
|
|
validator = emailValidator.validate();
|
|
|
|
if (validator.type == ValidationResultEvent.VALID)
|
|
{
|
|
this.errorString = "";
|
|
} else {
|
|
this.errorString = validator.message;
|
|
}
|
|
}
|
|
}
|
|
}
|