Actionscript – Restrict numbers 1-10 in textInput Box in Flex

actionscriptactionscript-3apache-flexflex3flex4

I have a TextInput box. I have to restrict a range more than 1,2,3,4,5,6,7,8,9,10 numbers only in the text Box.If i enter any number above that it should be allowed. If enter 11 or more than that, it should not allow to enter. it should allow from 1- 10 digits in the text box.
If enter 11 or 0 it should not allow and more than 10 should not allowed.

Please help me how to restrict it in TextInput Box in Flex. If any one knows about thte regular expression, please help me out .

Best Answer

If the only thing that the user can input are numbers 1 to 10,
try using the NumericStepper component instead.

This component has the features you describe built in.

For example:

<s:NumericStepper minimum="1" maximum="10" value="0" stepSize="1" maxChars="10"/>

Where:

  • minimum is the minimum allowed value
  • maximum is the maximum allowed value
  • value is the initial value
  • maxChars is the amount of characters allowed
  • stepsize is the amount by which the amount can be increased or decreased with the arrow buttons

Check out the livedocs:

Cheers

Related Topic