topical media & game development
mashup-rmx-08-ConfirmTextFieldValidator.ax
mashup-rmx-08-ConfirmTextFieldValidator.ax
(swf
)
[ flash
]
flex
package com.almerblank.flex.utils.validators
{
import mx.validators.StringValidator;
import mx.validators.ValidationResult;
import mx.core.UIComponent;
public class ConfirmTextFieldValidator extends StringValidator
{
[Bindable] public var confirmAgainst:UIComponent;
[Bindable] public var validationProperty:String = 'text';
[Bindable] public var fieldsDontMatchError:String = "The fields do not match, please make sure both fields match";
public function ConfirmTextFieldValidator()
{
super();
}
override protected function doValidation(value:Object):Array
{
var result:Array = super.doValidation(value);
var r:ValidationResult;
if (result.length == 0)
{
if (value != confirmAgainst[validationProperty])
{
r = new ValidationResult(true);
r.errorMessage = fieldsDontMatchError;
result.push(r);
}
else if (value == confirmAgainst[validationProperty])
{
// do nothing
}
else
{
r = new ValidationResult(true);
r.errorMessage = fieldsDontMatchError;
result.push(r);
}
}
return result;
}
}
}
(C) Æliens
18/6/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.