2 Replies Latest reply: Jul 9, 2014 4:34 AM by sana12_khan RSS

    restrict ,.(comma) for multiple numericstepper in a page

    sana12_khan

      Hi.

       

      i am trying to restrict ,.(comma) in numericstepper , i am bale to achieve it by using

       

      <s:NumericStepper id="datastoreCountInput" fontWeight="normal" creationComplete="validateTxtInput()" ..............  />

       

      my validate function is

       

      private function validateTxtInput():void {

        datastoreCountInput.textDisplay.restrict ='0-9';

        }

       

      my question is i have multiple NumericStepper in my page i wanted to use the same function for all of them . so i wanted to pass the current NumericStepper  object/id to the function.

      so that i can use the object in place of datastoreCountInput and restrict teh input value. As i am new to flex . looking for help here.

       

      Thanks in advance

        • 1. Re: restrict ,.(comma) for multiple numericstepper in a page
          sana12_khan

          can someone please replay to this

          • 2. Re: restrict ,.(comma) for multiple numericstepper in a page
            sana12_khan

            ok i figured it out , below is the code if anyone else is looking for it (but you need to have default value set if user left blank )

            In my case it will be always default value will be 1 if it is blank , so it works

             

            <?xml version="1.0"?>

            <!-- validators\ReusableValsSpecifySource.mxml -->

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                xmlns:s="library://ns.adobe.com/flex/spark"

                xmlns:mx="library://ns.adobe.com/flex/mx">

              <s:layout>

              <s:VerticalLayout/>

              </s:layout>

             

              <fx:Script>

              <![CDATA[

             

              import flash.events.Event;

              private static const DEFAULT_SNAP_WARNING_PERCENT:String = '0-9';

             

             

             

              private function validateTxtInput(eventObj:Event):void {

             

              eventObj.currentTarget.textDisplay.restrict = DEFAULT_SNAP_WARNING_PERCENT;

              }

             

              private function numericStepperParserMin1(value:String):Number {

              return !value ? 1 : Number(value);  

              }

             

             

              ]]>

              </fx:Script>

             

              <s:HGroup verticalAlign="middle" fontWeight="normal">

              <s:NumericStepper id="snapReserveInput" width="68" creationComplete="validateTxtInput(event)"

               minimum="0" maximum="9999" snapInterval="1" maxChars="4" />

              <s:Label text="testing"/>

              </s:HGroup>

              <s:HGroup verticalAlign="middle" fontWeight="normal">

              <s:NumericStepper id="snapReserveInput1" width="68" creationComplete="validateTxtInput(event)"

               valueParseFunction="numericStepperParserMin1"

               minimum="0" maximum="9999" snapInterval="1" maxChars="4" />

              <s:Label text="testing1"/>

              </s:HGroup>

             

             

            </s:Application>