警报被触发多次 [英] Alert is triggered multiple times
问题描述
以下code工作在下列方式:
当我在 txtother.textbox 输入不正确的价值观和专注了,警报将显示为请输入有效的格式掩码。。 pressing的确定按钮,在Alertbox在 txtOther.focusout 即使再次被触发。 即后马上pressing在确定警报,同样的 ALERT 将再次显示。
When I enter incorrect values in the txtother.textbox and focuses out, an alert will be displayed as "Please enter a valid Format Mask." . After pressing the "ok" button in the Alertbox the txtOther.focusout even is triggered again. i.e. immediately after pressing the OK of alert, the same ALERT is displayed again.
我已经加入了code乌拉圭回合参考:
I have added the code for ur reference:
//in mxml File:
<mx:Canvas label="General" >
<mx:VBox>
<mx:Canvas id="cvsGeneral">
<mx:TextInput id="txtOther" focusOut="txtOther_Validate();"/>
</mx:Canvas>
</mx:VBox>
</mx:Canvas>
<mx:Canvas width="100%" height="5%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:HBox width="80%" height="100%" horizontalAlign="left">
<mx:Button width="64" label="Save" id="btnSave" click="btnSave_Click();" focusIn="txtOther_Validate();"/>
</mx:HBox>
</mx:Canvas>
//Validating action script is as follows:
public function txtOther_Validate():void{
var formatMask: String = null;
if(txtOther.editable && txtOther.enabled){
if(txtOther.text != ""){
formatMask = txtOther.text;
if(conditions to validate){
//some expression
}
if(formatMask.length < 12){
Alert.show("Please enter format mask with minimum 12 digits.");
txtOther.setFocus();
return;
} VariableEditControl.getInstance().validateFormatMask(txtOther.text,validateFormatMask_Result,validateFormatMask_Fault, validateFormatMask_Error);
}
}
}
public function validateFormatMask_Result(event:PLEvent): void {
var result:String = event.getData().toString(); // here lets assume that the result variable is stored as "FAILURE"
if(result == "FAILURE"){
Alert.show("Please enter a valid Format Mask.");
txtOther.setFocus(); //
}
}
我不想警报一次又一次地来..
我需要它以这样一种方式,当警报的确定按钮pressed。该 txtother.text
应成为市场关注焦点,并警告不要像以前那样来一次又一次。
I don't want to the alert to come again and again ..
I need it in such a way that when the ok button of alert is pressed. The txtother.text
should be in focus, and the alert should not come again and again as before.
推荐答案
那是因为你有的focusIn =txtOther_Validate();
确定按钮第二次。只是删除的focusIn处理程序,你应该罚款。
it's because you have the focusIn="txtOther_Validate();"
on the ok button a second time. just remove the focusIn handler and you should be fine.
这篇关于警报被触发多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!