Flex NumericStepper: limit range of integer part before the decimal point

1.5k Views Asked by At

I have a NumericStepper in flex that must accept values between 0 and 999.99.

I tried setting the numericStepper as follows:

    <s:NumericStepper id="numStepper" value="@{myValue}" maximum="999.99" snapInterval="0.01" stepSize="0.01" minimum="0"/>

and setting also a NumberValidator attached to it:

var nValidator:NumberValidator = new NumberValidator();
nValidator.source = numStepper;
nValidator.precision = 2;
numericStepper.maxChars=6;
nValidator.decimalSeparator=".";

The thing works but I would like also to directly limit the user input via keyboard in the numeric stepper, so that the user can't type things like "1.4567" but only 1.45.

So I want something to limit the integer and decimal part of the number according to my specifications:

  1. max 3 chars integer part
  2. "." decimal separator
  3. max 2 chars precision

Maybe some regular expression can help?

Thanks

1

There are 1 best solutions below

5
Kaushal De Silva On BEST ANSWER

Have you tried...

nValidator.fractionalDigits = 2;