![](/img/trans.png)
[英]flex 3 number input validation on text field (restrict range to 1-100)
[英]Validation in flex input text field
我有一個flex程序,其中我檢查特定字段是否經過驗證,然后啟用提交按鈕。 我正在嘗試這樣的事情:
public function init():void
{
submit.addEventListener(Event.CHANGE,enableSubmit);
}
public function enableSubmit(event:TextInput):void
{
//some code to enable the button
}
我可以在創建完成時調用init來添加事件監聽器以提交! 這是正確的方法嗎? 請幫忙!
是的,您可以在creationComplete
調用init
。 您只需在代碼中進行更改,就是將enableSubmit
的參數從TextInput
更改為Event
因為事件是通過參數傳遞的,例如以下代碼:
public function enableSubmit(event:Event):void
{
//some code to enable the button
}
另外,事件偵聽器也需要添加到TextInput中,因此我假設提交控件為TextInput submit.addEventListener(Event.CHANGE,enableSubmit);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.