3 Replies Latest reply on Jan 18, 2012 7:53 AM by Rahul7777

    flex validations

    Rahul7777

           Hi everyone,

                                 My application has 8 modules and each with around 25 fields, for validation, i should have 200 validators??, can i hook all phonenumbers to one like that,

       

      Ex:

       

       

               HomePhone, OfficePhone, CellPhone should have one call to validator not 3 validators,

       

       

       

      <mx:StringValidator id="validContactTitle"

                                  source="{tiContactTitle}"

                                  property="text"

                                  valid="ValidField(event)"

                                  invalid="InvalidField(event,data,'JobTitle_Required')"

                                  />

       

      Here source can take any arrayCollection like that i googled but with no luck...

       

      Based on valid or invalid i have to do lot of logic inside so i  can't loop it.

       

       

      any help is appreciated.

        • 1. Re: flex validations
          senthil s Level 1

          Hi Rahul ,   You can use single validater for several sources    eg:            if you are using 4 textinput means  use that id as validater source  eg:  string_Validater.source=TextInput_id_1; string_Validater.source=TextInput_id_2; string_Validater.source=TextInput_id_3; string_Validater.source=TextInput_id_4;  Try dis it will work...  Reg, Senthil.

          • 2. Re: flex validations
            Rahul7777 Level 1

            Thanks senthil for your reply,

             

            i think validator source is of type object, it will take the last one, not all

             

            x=y;

            x=i;

            x=j;

            x=k;

             

            x will be k right????

             

            let me try and give you quick reply .

            • 3. Re: flex validations
              Rahul7777 Level 1

              Can you run this example: will give you some idea.

               

               

              <?xml version="1.0" encoding="utf-8"?>

              <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"

                             minWidth="955" minHeight="600"

                             creationComplete="application1_creationCompleteHandler(event)">

                  <fx:Script>

                      <![CDATA[

                          import mx.events.FlexEvent;

                          import mx.events.ValidationResultEvent;

                         

                          protected function application1_creationCompleteHandler(event:FlexEvent):void

                          {

                              pnV.source = phoneInput;

                              pnV.source = zipCodeInput;

                              pnV.source = city;

                              pnV.source = state;

                          }

                         

                         

                          protected function pnV_validHandler(event:ValidationResultEvent):void

                          {

                              trace("valid handler " + event.currentTarget.source.name);

                          }

                         

                         

                          protected function pnV_invalidHandler(event:ValidationResultEvent):void

                          {

                              trace("invalid " + event.currentTarget.source.name);

                          }

                         

                      ]]>

                  </fx:Script>

                  <fx:Declarations>

                      <!-- Place non-visual elements (e.g., services, value objects) here -->

                      <mx:PhoneNumberValidator id="pnV"

                                               property="text" valid="pnV_validHandler(event)" invalid="pnV_invalidHandler(event)"/>

                  </fx:Declarations>

                 

                 

                  <s:VGroup>

                      <mx:TextInput id="phoneInput" name="phone"/>

                      <mx:TextInput id="zipCodeInput" name="zip"/>

                      <mx:TextInput id="city" name="city"/>

                      <mx:TextInput id="state" name="state"/>

                  </s:VGroup>

              </s:Application>