5 Replies Latest reply on Mar 20, 2014 10:04 AM by ivanoff

    Help with realization of a code by "change" event

    ivanoff

      The form is developed in Live Cycle 9

       

      There is the following code:

      var str = rawValue;

      var FIO = str.split (' ');

      var a = FIO.length

      switch (a) {

      case 2:{

              FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

              FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

          rawValue = FIO.join (' ');

                break;

      }

           case 3:{

              FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

              FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

              FIO [2] = FIO [2].charAt (0).toUpperCase () + FIO [2].substr (1);

         rawValue = FIO.join (' ');

                      break;

      }

      case 4:{

              FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

              FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

              FIO [2] = FIO [2].charAt (0).toUpperCase () + FIO [2].substr (1);

              FIO [3] = FIO [3].charAt (0) + FIO [3].substr (1);

          rawValue = FIO.join (' ');

                 break;

      }

        default:

          rawValue = str;  

         }

      }

       

      This code works on "exit" event (transfers the first symbols of the first three words to the top register, input of all text happens in the bottom register). How to make the given functionality on "change" event. It is necessary that at once at text input in the field the first symbols of the first those words were removed in the top register.

        • 1. Re: Help with realization of a code by "change" event
          Magus069 Level 4

          where does rawValue come from?

          you need to specify which object you want to get the value from,

          if its the object you are coding in, you must write:  this.rawValue

          • 2. Re: Help with realization of a code by "change" event
            ivanoff Level 1

              <field name="Strachovatel" y="3.65mm" x="48.65mm" w="125mm" h="10mm">

                        <ui>

                           <textEdit>

                              <border>

                                 <?templateDesigner StyleID aped3?>

                                 <edge stroke="lowered"/>

                              </border>

                              <margin/>

                           </textEdit>

                        </ui>

                        <font typeface="Myriad Pro"/>

                        <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>

                        <para vAlign="middle"/>

                        <caption reserve="25mm">

                           <para vAlign="middle"/>

                           <value>

                              <text>Текстовое поле</text>

                           </value>

                        </caption>

                        <event activity="exit" name="event__exit">

                           <script contentType="application/x-javascript">var str = rawValue;

            var FIO = str.split (' ');

            var a = FIO.length

            switch (a) {

            case 2:{

                          FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

                          FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

                        rawValue = FIO.join (' ');

                      break;

            }

                 case 3:{

                    FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

                    FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

                    FIO [2] = FIO [2].charAt (0).toUpperCase () + FIO [2].substr (1);

               rawValue = FIO.join (' ');

                            break;

            }

            case 4:{

                    FIO [0] = FIO [0].charAt (0).toUpperCase () + FIO [0].substr (1);

                    FIO [1] = FIO [1].charAt (0).toUpperCase () + FIO [1].substr (1);

                    FIO [2] = FIO [2].charAt (0).toUpperCase () + FIO [2].substr (1);

                    FIO [3] = FIO [3].charAt (0) + FIO [3].substr (1);

                rawValue = FIO.join (' ');

                       break;

            }

              default:

                rawValue = str;  

               }

            </script>

                        </event>

                     </field>

            • 3. Re: Help with realization of a code by "change" event
              Magus069 Level 4

              you must indicate which rawValue you want to work with...

               

              using this.rawValue is equivalent to write Strachovatel.rawValue

              if you mean another object's rawValue you will have to access to that object before writing rawValue

              • 4. Re: Help with realization of a code by "change" event
                ivanoff Level 1

                I need something like these:

                <field name="Strachovatel" y="8.65mm" x="3.65mm" w="170mm" h="10mm">

                            <ui>

                               <textEdit>

                                  <border>

                                     <?templateDesigner StyleID aped3?>

                                     <edge stroke="lowered"/>

                                  </border>

                                  <margin/>

                               </textEdit>

                            </ui>

                            <font typeface="Myriad Pro"/>

                            <margin topInset="1mm" bottomInset="1mm" leftInset="1mm" rightInset="1mm"/>

                            <para vAlign="middle"/>

                            <caption reserve="45.707mm">

                               <para vAlign="middle"/>

                               <value>

                                  <text>toUpperCase</text>

                               </value>

                            </caption>

                            <event activity="change" name="event__change">

                               <script contentType="application/x-javascript">

                 

                if (xfa.event.newText.length &gt;xfa.event.prevText.length &amp;&amp;xfa.event.change.length == 1)

                {

                1. xfa.event.change = xfa.form.topmostSubform.variables.Validation.VerchReg(xfa.event.change);

                }

                else

                {

                1. xfa.event.change = "";

                }      

                       

                </script>

                            </event>

                         </field>

                   <?templateDesigner expand 1?></subform>

                      <proto/>

                      <desc>

                         <text name="version">9.0.0.2.20120627.2.874785</text>

                      </desc>

                      <?templateDesigner Hyphenation excludeInitialCap:1, excludeAllCaps:1, wordCharCnt:7, remainCharCnt:3, pushCharCnt:3?>

                      <variables>

                         <script contentType="application/x-javascript" name="Validation">

                var first=true;

                function VerchReg(newsymbol)

                {

                var re = /[А-Яа-я-" "]/;

                if (re.test(newsymbol))

                {

                if (newsymbol==" ")

                {

                  first=true;

                  return newsymbol;

                }

                if (first)

                {

                first=false;

                return newsymbol.toUpperCase();

                }

                else

                {

                return newsymbol;

                }

                }

                else

                {

                return "";

                }

                }

                </script>

                         <?templateDesigner expand 1?></variables>

                      <?templateDesigner expand 1?></subform>

                Here only the first character of all words are written in upper case, and we need only the first three words.

                • 5. Re: Help with realization of a code by "change" event
                  ivanoff Level 1

                  Thu, 20 Mar 2014 09:19:51 -0700 от Robert Gagnon Ranger <forums_noreply@adobe.com>:

                  >Re: Help with realization of a code by "change" event created by  Robert Gagnon Ranger in  LiveCycle Forms -  View the full discussion