i want to make an input text validation with FLASH ActionScript 2. The input text only displaying numbers above 5, so if i try to input number 0,1,2,3,4, the Alert will pop up and give an information that the data should be above 5.
i want the validation processing while the input text is changing, because i dont use any button as the trigger.
import mx.controls.Alert;
var tiListener:Object = new Object();
tiListener.change = function(evt_obj:Object)
{
if(inputText.text < 5)
{
trace("Numbers below 5 are not allowed");
Alert.show("Numbers below 5 are not allowed", "Error");
inputText.setFocus();
};
};
proj.addEventListener("change", tiListener);
Trace output is working well, but the Alert not shown. Any body have any solution? Thanks..
The type of your inputText text is
string, and you want it to benumber. Use theparseIntmethod to convert your string to aninteger:Place this code into your function, and that will be more clear: