简体   繁体   中英

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

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

你有没有尝试过...

nValidator.fractionalDigits = 2;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM