topical media & game development
mashup-rmx-08-RMXFormExample-com-almerblank-libs-flex-validators-ConfirmTextFieldValidator.ax
mashup-rmx-08-RMXFormExample-com-almerblank-libs-flex-validators-ConfirmTextFieldValidator.ax
(swf
)
[ flash
]
flex
package com.almerblank.libs.flex.validators
{
import mx.validators.StringValidator;
import mx.validators.ValidationResult;
public class ConfirmTextFieldValidator extends StringValidator
{
[Bindable]
public var confirmAgainst:*;
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.text)
{
r = new ValidationResult(true);
r.errorMessage = fieldsDontMatchError;
result.push(r);
}
else if (value == confirmAgainst.text)
{
// 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.