Brian Genisio
Brian Genisio

Reputation: 48137

Why can't I restrict a NumericStepper to include the negative sign?

I want to restrict my NumericStepper so that you can't type invalid characters into it (like a comma). I'm trying this, and it works:

<s:initialize>
    stepper.textDisplay.restrict = "0-9 \- .";
</s:initialize>

<s:NumericStepper id="stepper" />

Except the negative sign can't be typed anymore, even though I specify it.

If I do it directly on a TextInput, it works:

<s:TextInput restrict="0-9 \- ." minimum="-10" />

Why doesn't this work?

Upvotes: 3

Views: 1628

Answers (1)

Exhausted
Exhausted

Reputation: 1885

The thing is Numeric Stepper Allows only the Three Special Characters .,- the text display in the numeric stepper is restricted to

textDisplay.restrict = "0-9\\-\\.\\,";

Since if you want to restrict the -,. you can use like this

<s:initialize>
    stepper.textDisplay.restrict = "0-9";
</s:initialize>

<s:NumericStepper id="stepper" />

this is quite enough and worked for me, the same can be used for the s:TextInput. The Format you used is not correct, the accepted backslash sequences are \-, \^ or \\ while using the ActionScript a double backslash must be used.

For More Information refer the Document here.

Upvotes: 3

Related Questions