Min & Max values in TextInput
Hi there,
Just found this piece of code as I was looking for something on the fly to use for a min and max value for a Input Text Box.
Max value works fine yet I can't work out the min. I was actually looking for two different items here and maybe somebody could help !!!
1) Strait forward max value of 540 sec. and another value of a max and min value of 500 to 540 sec. ???
2) Strait forward min value of 15 sec. and another of a min value of 15 to say 20 sec. ???
Any help would be very much appreciated !! regards aktell
Code:
<mx:TextInput
maxChars="3"
restrict="[0-9]"
change="handleTextChanges(event)"/>
Code:
private function handleTextChanges(evt:Event):void {
var target:TextInput = evt.currentTarget as TextInput;
if(!target) return;
if(parseInt(target.text) > 540) {
Alert.show("You can't enter a number grater than 540");
target.text = "540";
}
}