1 Reply Latest reply on Jan 17, 2012 11:28 AM by PierreSolutions

    TextInput - Limit entered value

    Zolotoj Level 3

      How can I limit a value being entered into a TextInpit? For example, I only let enter values from 1 to 10. If a user types 1 and then 1 again, I want to show just 1, the last entered key should be ignored.

       

      Any idea? Thanks

        • 1. Re: TextInput - Limit entered value
          PierreSolutions Level 2

          My first thought would be not to use a textInput, and to use a numericStepper, but that is not Mobile Optimized.

          You could use a spinnerList instead or mock up a numericStepper with a readOnly textInput and a + and a - button that increase or decrease the value within the confines you want.

           

          If you MUST use a textInput, maybe try double binding the text property of the textInput to a the property of an object that implements the behavior you are looking for.

          For example:

           

          <s:textInput text="@{myObj.smartText}" />

           

          and myObj:SmartObj = new SmartObj();

           

          and in the definition of the SmartObj class, smartText is a value accessible through getters and setters that implement the behavior you are looking for.

           

          Not sure it would work, I have not tried it, but that is what I thought.