如何以编程方式从Flex组件删除确认 这是我的方法
How to remove validation programmatically from flex component This is my method
public static function validateRequired(txt:TextInput, errorMessage:String="This field is required"):Boolean
{
var v:Validator = new Validator();
v.listener = txt;
var result:ValidationResultEvent = v.validate(txt.text);
var returnResult:Boolean = (result.type == ValidationResultEvent.VALID);
//Alert.show("validation result is " + returnResult);
if (!returnResult) {
v.requiredFieldError = errorMessage;
}
return returnResult;
}
但是,随着每一次我创建新的验证,所以弹出包含如
But, as each time i am creating new validator, so pop-up contains multiple messages like
此字段是必需的。 此字段是必需的。
This field is required. This field is required.
如何去除附在与组件的错误信息?
How to remove error messages attached with component?
在Validator.enabled属性,可以启用和禁用验证。当enabled属性的值是true,验证程序被启用;当值为false时,禁用验证程序。当禁用验证程序后,将分派任何事件,而validate()方法返回null。
The Validator.enabled property lets you enable and disable a validator. When the value of the enabled property is true, the validator is enabled; when the value is false, the validator is disabled. When a validator is disabled, it dispatches no events, and the validate() method returns null.
例如,您可以设置使用数据绑定,enabled属性如下code所示:
For example, you can set the enabled property by using data binding, as the following code shows:
<?xml version="1.0"?>
<!-- validators\EnableVal.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:ZipCodeValidator id="zcVal"
source="{inputA}"
property="text"
required="true"
enabled="{enableV.selected}"/>
<mx:TextInput id="inputA"/>
<mx:TextInput/>
<mx:CheckBox id="enableV"
label="Validate input?"/>
</mx:Application>
上一篇:为什么drawRoundRectComplex()在ActionScript记录?drawRoundRectComplex、ActionScript
下一篇:从引发Event.COMPLETE如何获得相关的URLRequest通过的URLLoader发射如何获得、COMPLETE、Event、URLRequest