Merge remote-tracking branch 'PracticingFlex/master'
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user