Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Validation of Text Fields (LCD 8.0)

Avatar

Level 2

Hello,

I have a text field where users enter a code consisting af one of four letters, say B, C, D, or E, followed by 4 digits, e.g. B0123.  I know how to validate the pattern to get a character followed by 4 digits using A9999 in the Value-->Validation Pattern.  But that allows G1234, and G is not an ``allowed'' letter.

Now, I'd like to use something like the following for the validation pattern in order to make sure that only the 4 allowed letters are used:

Validation Pattern: 'B'9999 | 'C'9999 | 'D'9999 | 'E'9999

Unfortunately, this doesn't work.  Any suggestions how to achieve my goal?  (No, a drop-down list is not an option, since there are hundreds of possible options).

Thanks and Cheers

Markus

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You have the script saved in wrong position also need to set up 'A9999' as Validation rule.

Here you go...........

<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="AdobeLiveCycleDesigner_V8.0" APIVersion="2.5.6290.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2009-05-28T21:01:36Z" uuid="20ed2889-046c-4f10-b0f1-0fd547c50b92">
<template xmlns="http://www.xfa.org/schema/xfa-template/2.5/">
   <subform name="form1" layout="tb" locale="en_US">
      <pageSet>
         <pageArea name="Page1" id="Page1">
            <contentArea x="0.25in" y="0.25in" w="8in" h="10.5in"/>
            <medium stock="letter" short="8.5in" long="11in"/>
            <?templateDesigner expand 1?></pageArea>
         <?templateDesigner expand 1?></pageSet>
      <subform w="8in" h="10.5in">
         <field h="9.525mm" name="Project" w="28.575mm" x="53.975mm" y="15.875mm">
            <ui>
               <textEdit>
                  <border>
                     <edge presence="hidden">
                     </edge>
                     <fill>
                        <color value="194,224,246"/>
                     </fill>
                     <corner presence="hidden"/>
                  </border>
                  <margin/>
               </textEdit>
               <picture>A9999</picture>
            </ui>
            <font typeface="Myriad Pro"/>
            <margin bottomInset="1mm" leftInset="1mm" rightInset="1mm" topInset="1mm"/>
            <para vAlign="middle"/>
            <caption reserve="15.4984mm">
               <font typeface="Myriad Pro"/>
               <para vAlign="middle"/>
               <value>
                  <text>Project #:</text>
               </value>
            </caption>
            <border>
               <edge/>
               <corner thickness="0.1753mm"/>
            </border>
            <format>
               <picture>A9999</picture>
            </format>
            <validate>
               <picture>A9999</picture>
            </validate>
            <?templateDesigner ScriptInitializers exit::lang=JavaScript;?>
            <event activity="exit">
               <script contentType="application/x-javascript">var ProjectNo=this.rawValue;
var subSection = ProjectNo.substring(1,0);
if(subSection == "R"){
//good
} else if(subSection == "D"){
//good
} else if(subSection == "G"){
//good
} else if(subSection == "S"){
//good
} else if(subSection == "C"){
//good
} else {
xfa.host.messageBox("Value in this should start with one of R, D, G, S, C");
}</script>
            </event>
         </field>
         <?templateDesigner expand 1?></subform>
      <proto/>
      <desc>
         <text name="version">8.0.1291.1.339988.308172</text>
      </desc>
      <?templateDesigner expand 1?></subform>
   <?templateDesigner DefaultLanguage FormCalc?>
   <?templateDesigner DefaultRunAt client?>
   <?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>
   <?templateDesigner Zoom 86?>
   <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template>
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
   <agent name="designer">
      <destination>pdf</destination>
      <pdf>
         <!--  [0..n]  -->
         <fontInfo/>
      </pdf>
   </agent>
   <trace>
      <area name="font" level="1"/>
   </trace>
   <present>
      <!--  [0..n]  -->
      <destination>pdf</destination>
      <pdf>
         <!--  [0..n]  -->
         <fontInfo>
            <embed>1</embed>
            <subsetBelow>100</subsetBelow>
         </fontInfo>
         <version>1.65</version>
         <creator>Adobe LiveCycle Designer 8.0</creator>
         <producer>Adobe LiveCycle Designer 8.0</producer>
         <scriptModel>XFA</scriptModel>
         <interactive>1</interactive>
         <tagged>1</tagged>
         <compression>
            <level>6</level>
            <compressLogicalStructure>1</compressLogicalStructure>
            <type/>
         </compression>
         <linearized>1</linearized>
         <batchOutput/>
         <encryption>
            <encrypt/>
            <permissions>
               <accessibleContent>1</accessibleContent>
               <contentCopy>1</contentCopy>
               <documentAssembly>1</documentAssembly>
               <formFieldFilling>1</formFieldFilling>
               <modifyAnnots>1</modifyAnnots>
               <print>1</print>
               <printHighQuality>1</printHighQuality>
               <change>1</change>
               <plaintextMetadata>1</plaintextMetadata>
            </permissions>
         </encryption>
         <openAction>
            <destination/>
         </openAction>
         <taggedMode/>
         <viewerPreferences>
            <addViewerPreferences/>
            <duplexOption/>
            <numberOfCopies/>
            <pageRange/>
         </viewerPreferences>
         <silentPrint>
            <addSilentPrint/>
            <printerName/>
         </silentPrint>
         <renderPolicy/>
      </pdf>
      <common>
         <template>
            <relevant/>
            <base>C:\Documents and Settings\5469\My Documents\</base>
            <uri/>
         </template>
         <data>
            <uri/>
            <adjustData>1</adjustData>
            <xsl>
               <uri/>
            </xsl>
            <outputXSL>
               <uri/>
            </outputXSL>
         </data>
         <messaging/>
         <log>
            <to>uri</to>
            <uri>C:\DOCUME~1\5469\LOCALS~1\Temp\_c7k18f7p4a1d33r1n.log</uri>
            <mode>overwrite</mode>
            <threshold/>
         </log>
         <locale/>
      </common>
      <xdp>
         <packets>*</packets>
      </xdp>
      <cache>
         <renderCache/>
      </cache>
      <incrementalMerge/>
      <script>
         <runScripts/>
         <exclude/>
      </script>
      <pagination/>
      <copies/>
      <layout/>
      <output>
         <to>uri</to>
         <uri>C:\DOCUME~1\5469\LOCALS~1\Temp\_c7k18f7p4a1d33r1n.pdf</uri>
      </output>
   </present>
   <acrobat>
      <acrobat7>
         <dynamicRender>forbidden</dynamicRender>
      </acrobat7>
      <common>
         <locale/>
         <data>
            <uri/>
            <adjustData>1</adjustData>
            <xsl>
               <uri/>
            </xsl>
            <outputXSL>
               <uri/>
            </outputXSL>
         </data>
         <template>
            <relevant/>
            <base>C:\Documents and Settings\5469\My Documents\</base>
            <uri/>
         </template>
      </common>
   </acrobat>
   <psMap/>
</config>
<localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.1/">
   <locale name="en_US" desc="English (United States)">
      <calendarSymbols name="gregorian">
         <monthNames>
            <month>January</month>
            <month>February</month>
            <month>March</month>
            <month>April</month>
            <month>May</month>
            <month>June</month>
            <month>July</month>
            <month>August</month>
            <month>September</month>
            <month>October</month>
            <month>November</month>
            <month>December</month>
         </monthNames>
         <monthNames abbr="1">
            <month>Jan</month>
            <month>Feb</month>
            <month>Mar</month>
            <month>Apr</month>
            <month>May</month>
            <month>Jun</month>
            <month>Jul</month>
            <month>Aug</month>
            <month>Sep</month>
            <month>Oct</month>
            <month>Nov</month>
            <month>Dec</month>
         </monthNames>
         <dayNames>
            <day>Sunday</day>
            <day>Monday</day>
            <day>Tuesday</day>
            <day>Wednesday</day>
            <day>Thursday</day>
            <day>Friday</day>
            <day>Saturday</day>
         </dayNames>
         <dayNames abbr="1">
            <day>Sun</day>
            <day>Mon</day>
            <day>Tue</day>
            <day>Wed</day>
            <day>Thu</day>
            <day>Fri</day>
            <day>Sat</day>
         </dayNames>
         <meridiemNames>
            <meridiem>AM</meridiem>
            <meridiem>PM</meridiem>
         </meridiemNames>
         <eraNames>
            <era>BC</era>
            <era>AD</era>
         </eraNames>
      </calendarSymbols>
      <datePatterns>
         <datePattern name="full">EEEE, MMMM D, YYYY</datePattern>
         <datePattern name="long">MMMM D, YYYY</datePattern>
         <datePattern name="med">MMM D, YYYY</datePattern>
         <datePattern name="short">M/D/YY</datePattern>
      </datePatterns>
      <timePatterns>
         <timePattern name="full">h:MM:SS A Z</timePattern>
         <timePattern name="long">h:MM:SS A Z</timePattern>
         <timePattern name="med">h:MM:SS A</timePattern>
         <timePattern name="short">h:MM A</timePattern>
      </timePatterns>
      <dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols>
      <numberPatterns>
         <numberPattern name="numeric">z,zz9.zzz</numberPattern>
         <numberPattern name="currency">$z,zz9.99|($z,zz9.99)</numberPattern>
         <numberPattern name="percent">z,zz9%</numberPattern>
      </numberPatterns>
      <numberSymbols>
         <numberSymbol name="decimal">.</numberSymbol>
         <numberSymbol name="grouping">,</numberSymbol>
         <numberSymbol name="percent">%</numberSymbol>
         <numberSymbol name="minus">-</numberSymbol>
         <numberSymbol name="zero">0</numberSymbol>
      </numberSymbols>
      <currencySymbols>
         <currencySymbol name="symbol">$</currencySymbol>
         <currencySymbol name="isoname">USD</currencySymbol>
         <currencySymbol name="decimal">.</currencySymbol>
      </currencySymbols>
   </locale>
</localeSet>
<PDFSecurity print="1" printHighQuality="1" change="1" modifyAnnots="1" formFieldFilling="1" documentAssembly="1" contentCopy="1" accessibleContent="1" metadata="1" xmlns="http://ns.adobe.com/xtd/"/></xdp:xdp>

View solution in original post

7 Replies

Avatar

Former Community Member

Here is simple rout to overcome this.......I would use JS script similar to the following in 'exit' event of the Text field.

var element = this.rawValue;
var subSection = element.substring(1,0);

if(subSection == "B"){

     //good
}else if(subSection == "C") {
     //good

}else if(subSection == "D") {
     //good

}else if(subSection == "E") {
     //good

}else {
     xfa.host.messageBox("Value in this should start with one of B, C, D, E");
     xfa.host.setFocus("this.somExpression");
}

Avatar

Level 2

Hi LC Prof,

thanks for the pointer. Unfortunately, I'm new to this whole XML/JS thing.

Here's the complete XML code snippet for the field including my

attempt to adapt your suggestion:

<field h="9.525mm" name="Project" w="28.575mm" x="203.2mm" y="22.225mm"><br /> <ui><br /> <textEdit><br /> <border><br /> <edge presence="hidden"></edge><br /> <fill><br /> <color value="194,224,246"></color><br /> </fill><br /> <corner presence="hidden"></corner><br /> </border><br /> <margin></margin><br /> </textEdit><br /> <picture>A9999</picture><br /> </ui><br /> <font typeface="Myriad Pro"></font><br /> <margin bottomInset="1mm" leftInset="1mm" rightInset="1mm"<br />topInset="1mm"></margin><br /> <para vAlign="middle"></para><br /> <caption reserve="15.4984mm"><br /> <font typeface="Myriad Pro"></font><br /> <para vAlign="middle"></para><br /> <value><br /> <text>Project #:</text><br /> </value><br /> </caption><br /> <border><br /> <edge></edge><br /> <corner thickness="0.1753mm"></corner><br /> </border><br /> <format><br /> <picture>A9999</picture><br /> </format><br /> <exit><br /> var ProjectNo=Project;<br /> var subSection = ProjectNo.substring(1,0);<br /> if(subSection == "R"){<br /> //good<br /> } else if(subSection == "D"){<br /> //good<br /> } else if(subSection == "G"){<br /> //good<br /> } else if(subSection == "S"){<br /> //good<br /> } else if(subSection == "C"){<br /> //good<br /> } else {<br /> xfa.host.messageBox("Value in this should start with<br />one of B, C, D, E");<br /> }<br /> </exit><br /> </field>

This does not do anything, however. I'd really appreciate a hint as

to what I'm doing wrong. I'm assuming that it's a really obvious

newbie thing

Thanks and Cheers

Markus

Avatar

Level 2

Sorry, the code snippet didn't ake it.

Here it is:

        <field h="9.525mm" name="Project" w="28.575mm" x="203.2mm" y="22.225mm">

            <ui>

               <textEdit>

                  <border>

                     <edge presence="hidden"/>

                     <fill>

                        <color value="194,224,246"/>

                     </fill>

                     <corner presence="hidden"/>

                  </border>

                  <margin/>

               </textEdit>

               <picture>A9999</picture>

            </ui>

            <font typeface="Myriad Pro"/>

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

            <para vAlign="middle"/>

            <caption reserve="15.4984mm">

               <font typeface="Myriad Pro"/>

               <para vAlign="middle"/>

               <value>

                  <text>Project #:</text>

               </value>

            </caption>

            <border>

               <edge/>

               <corner thickness="0.1753mm"/>

            </border>

            <format>

               <picture>A9999</picture>

            </format>

            <exit>

               var ProjectNo=Project;

               var subSection = ProjectNo.substring(1,0);

               if(subSection == "R"){

                  //good

               } else if(subSection == "D"){

                  //good

               } else if(subSection == "G"){

                  //good

               } else if(subSection == "S"){

                  //good

               } else if(subSection == "C"){

                  //good

               } else {

                  xfa.host.messageBox("Value in this should start with one of B, C, D, E");

               }

            </exit>

         </field>

Markus

Avatar

Former Community Member

Replace line var ProjectNo=Project; with one of the following and make sure you have seleted the Language to "JavaScript" on the script window. Then try it worked for me it should work for you. Attach your copy if you still have issues.

var ProjectNo=Project.rawValue;

or

var ProjectNo=this.rawValue;

Avatar

Level 2

i did that, but still nothing happened.  Maybe I'm doing something completely wrong ...

Attached is a test pdf file, and pasted below is the corresponding complete XML code.  Maybe that'll help you show me what I'm doing wrong ...

Thanks so much for youer time and help, I appreciate it a lot!

Markus

XML Code:

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

<?xfa generator="AdobeLiveCycleDesigner_V8.0" APIVersion="2.5.6290.0"?>

<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2009-05-28T21:01:36Z" uuid="20ed2889-046c-4f10-b0f1-0fd547c50b92">

<template xmlns="http://www.xfa.org/schema/xfa-template/2.5/">

   <subform name="form1" layout="tb" locale="en_US">

      <pageSet>

         <pageArea name="Page1" id="Page1">

            <contentArea x="0.25in" y="0.25in" w="8in" h="10.5in"/>

            <medium stock="letter" short="8.5in" long="11in"/>

            <?templateDesigner expand 1?></pageArea>

         <?templateDesigner expand 1?></pageSet>

      <subform w="8in" h="10.5in">

         <field h="9.525mm" name="Project" w="28.575mm" x="53.975mm" y="15.875mm">

            <ui>

               <textEdit>

                  <border>

                     <edge presence="hidden"/>

                     <fill>

                        <color value="194,224,246"/>

                     </fill>

                     <corner presence="hidden"/>

                  </border>

                  <margin/>

               </textEdit>

               <picture>A9999</picture>

            </ui>

            <font typeface="Myriad Pro"/>

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

            <para vAlign="middle"/>

            <caption reserve="15.4984mm">

               <font typeface="Myriad Pro"/>

               <para vAlign="middle"/>

               <value>

                  <text>Project #:</text>

               </value>

            </caption>

            <border>

               <edge/>

               <corner thickness="0.1753mm"/>

            </border>

            <format>

               <picture>A9999</picture>

            </format>

            <exit>

               var ProjectNo=this.rawValue;

               var subSection = ProjectNo.substring(1,0);

               if(subSection == "R"){

                  //good

               } else if(subSection == "D"){

                  //good

               } else if(subSection == "G"){

                  //good

               } else if(subSection == "S"){

                  //good

               } else if(subSection == "C"){

                  //good

               } else {

                  xfa.host.messageBox("Value in this should start with one of B, C, D, E");

               }

            </exit>

         </field>

         <?templateDesigner expand 1?></subform>

      <proto/>

      <desc>

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

      </desc>

      <?renderCache.subset "Myriad Pro" 0 0 ISO-8859-1 4 40 10 00010004001B003100440046004B005000530055 #:Pcejort?>

      <?templateDesigner expand 1?></subform>

   <?templateDesigner DefaultLanguage FormCalc?>

   <?templateDesigner DefaultRunAt client?>

   <?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>

   <?templateDesigner Zoom 97?>

   <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template>

<config xmlns="http://www.xfa.org/schema/xci/1.0/">

   <agent name="designer">

      <destination>pdf</destination>

      <pdf>

         <!--  [0..n]  -->

         <fontInfo/>

      </pdf>

   </agent>

   <trace>

      <area level="1" name="font"/>

   </trace>

   <present>

      <!--  [0..n]  -->

      <pdf>

         <!--  [0..n]  -->

         <fontInfo>

            <embed>1</embed>

            <subsetBelow>100</subsetBelow>

         </fontInfo>

         <version>1.65</version>

         <creator>Adobe LiveCycle Designer 8.0</creator>

         <producer>Adobe LiveCycle Designer 8.0</producer>

         <scriptModel>XFA</scriptModel>

         <interactive>1</interactive>

         <tagged>1</tagged>

         <compression>

            <level>6</level>

            <compressLogicalStructure>1</compressLogicalStructure>

            <type/>

         </compression>

         <linearized>1</linearized>

         <batchOutput/>

         <encryption>

            <encrypt/>

            <permissions>

               <accessibleContent>1</accessibleContent>

               <contentCopy>1</contentCopy>

               <documentAssembly>1</documentAssembly>

               <formFieldFilling>1</formFieldFilling>

               <modifyAnnots>1</modifyAnnots>

               <print>1</print>

               <printHighQuality>1</printHighQuality>

               <change>1</change>

               <plaintextMetadata>1</plaintextMetadata>

            </permissions>

         </encryption>

         <openAction>

            <destination/>

         </openAction>

         <taggedMode/>

         <viewerPreferences>

            <addViewerPreferences/>

            <duplexOption/>

            <numberOfCopies/>

            <pageRange/>

         </viewerPreferences>

         <silentPrint>

            <addSilentPrint/>

            <printerName/>

         </silentPrint>

         <renderPolicy/>

      </pdf>

      <common>

         <template>

            <relevant/>

            <base>H:\NMR\Services\Pricing_and_Ordering\</base>

            <uri/>

         </template>

         <data>

            <uri/>

            <adjustData>1</adjustData>

            <xsl>

               <uri/>

            </xsl>

            <outputXSL>

               <uri/>

            </outputXSL>

         </data>

         <messaging/>

         <log>

            <to>uri</to>

            <uri>C:\DOCUME~1\mheller\LOCALS~1\Temp\_a3k18f7p483ae6h1j.log</uri>

            <mode>overwrite</mode>

            <threshold/>

         </log>

         <locale/>

      </common>

      <xdp>

         <packets>*</packets>

      </xdp>

      <cache>

         <renderCache/>

      </cache>

      <incrementalMerge/>

      <script>

         <runScripts/>

         <exclude/>

      </script>

      <pagination/>

      <copies/>

      <layout/>

      <destination>pdf</destination>

      <output>

         <to>uri</to>

         <uri>C:\DOCUME~1\mheller\LOCALS~1\Temp\_a3k18f7p483ae6h1j.pdf</uri>

      </output>

   </present>

   <acrobat>

      <acrobat7>

         <dynamicRender>forbidden</dynamicRender>

      </acrobat7>

      <common>

         <locale/>

         <data>

            <uri/>

            <adjustData>1</adjustData>

            <xsl>

               <uri/>

            </xsl>

            <outputXSL>

               <uri/>

            </outputXSL>

         </data>

         <template>

            <relevant/>

            <base>H:\NMR\Services\Pricing_and_Ordering\</base>

            <uri/>

         </template>

      </common>

   </acrobat>

   <psMap/>

</config>

<localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.1/">

   <locale name="en_US" desc="English (United States)">

      <calendarSymbols name="gregorian">

         <monthNames>

            <month>January</month>

            <month>February</month>

            <month>March</month>

            <month>April</month>

            <month>May</month>

            <month>June</month>

            <month>July</month>

            <month>August</month>

            <month>September</month>

            <month>October</month>

            <month>November</month>

            <month>December</month>

         </monthNames>

         <monthNames abbr="1">

            <month>Jan</month>

            <month>Feb</month>

            <month>Mar</month>

            <month>Apr</month>

            <month>May</month>

            <month>Jun</month>

            <month>Jul</month>

            <month>Aug</month>

            <month>Sep</month>

            <month>Oct</month>

            <month>Nov</month>

            <month>Dec</month>

         </monthNames>

         <dayNames>

            <day>Sunday</day>

            <day>Monday</day>

            <day>Tuesday</day>

            <day>Wednesday</day>

            <day>Thursday</day>

            <day>Friday</day>

            <day>Saturday</day>

         </dayNames>

         <dayNames abbr="1">

            <day>Sun</day>

            <day>Mon</day>

            <day>Tue</day>

            <day>Wed</day>

            <day>Thu</day>

            <day>Fri</day>

            <day>Sat</day>

         </dayNames>

         <meridiemNames>

            <meridiem>AM</meridiem>

            <meridiem>PM</meridiem>

         </meridiemNames>

         <eraNames>

            <era>BC</era>

            <era>AD</era>

         </eraNames>

      </calendarSymbols>

      <datePatterns>

         <datePattern name="full">EEEE, MMMM D, YYYY</datePattern>

         <datePattern name="long">MMMM D, YYYY</datePattern>

         <datePattern name="med">MMM D, YYYY</datePattern>

         <datePattern name="short">M/D/YY</datePattern>

      </datePatterns>

      <timePatterns>

         <timePattern name="full">h:MM:SS A Z</timePattern>

         <timePattern name="long">h:MM:SS A Z</timePattern>

         <timePattern name="med">h:MM:SS A</timePattern>

         <timePattern name="short">h:MM A</timePattern>

      </timePatterns>

      <dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols>

      <numberPatterns>

         <numberPattern name="numeric">z,zz9.zzz</numberPattern>

         <numberPattern name="currency">$z,zz9.99|($z,zz9.99)</numberPattern>

         <numberPattern name="percent">z,zz9%</numberPattern>

      </numberPatterns>

      <numberSymbols>

         <numberSymbol name="decimal">.</numberSymbol>

         <numberSymbol name="grouping">,</numberSymbol>

         <numberSymbol name="percent">%</numberSymbol>

         <numberSymbol name="minus">-</numberSymbol>

         <numberSymbol name="zero">0</numberSymbol>

      </numberSymbols>

      <currencySymbols>

         <currencySymbol name="symbol">$</currencySymbol>

         <currencySymbol name="isoname">USD</currencySymbol>

         <currencySymbol name="decimal">.</currencySymbol>

      </currencySymbols>

   </locale>

</localeSet>

<PDFSecurity print="1" printHighQuality="1" change="1" modifyAnnots="1" formFieldFilling="1" documentAssembly="1" contentCopy="1" accessibleContent="1" metadata="1" xmlns="http://ns.adobe.com/xtd/"/></xdp:xdp>

Avatar

Correct answer by
Former Community Member

You have the script saved in wrong position also need to set up 'A9999' as Validation rule.

Here you go...........

<?xml version="1.0" encoding="UTF-8"?>
<?xfa generator="AdobeLiveCycleDesigner_V8.0" APIVersion="2.5.6290.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2009-05-28T21:01:36Z" uuid="20ed2889-046c-4f10-b0f1-0fd547c50b92">
<template xmlns="http://www.xfa.org/schema/xfa-template/2.5/">
   <subform name="form1" layout="tb" locale="en_US">
      <pageSet>
         <pageArea name="Page1" id="Page1">
            <contentArea x="0.25in" y="0.25in" w="8in" h="10.5in"/>
            <medium stock="letter" short="8.5in" long="11in"/>
            <?templateDesigner expand 1?></pageArea>
         <?templateDesigner expand 1?></pageSet>
      <subform w="8in" h="10.5in">
         <field h="9.525mm" name="Project" w="28.575mm" x="53.975mm" y="15.875mm">
            <ui>
               <textEdit>
                  <border>
                     <edge presence="hidden">
                     </edge>
                     <fill>
                        <color value="194,224,246"/>
                     </fill>
                     <corner presence="hidden"/>
                  </border>
                  <margin/>
               </textEdit>
               <picture>A9999</picture>
            </ui>
            <font typeface="Myriad Pro"/>
            <margin bottomInset="1mm" leftInset="1mm" rightInset="1mm" topInset="1mm"/>
            <para vAlign="middle"/>
            <caption reserve="15.4984mm">
               <font typeface="Myriad Pro"/>
               <para vAlign="middle"/>
               <value>
                  <text>Project #:</text>
               </value>
            </caption>
            <border>
               <edge/>
               <corner thickness="0.1753mm"/>
            </border>
            <format>
               <picture>A9999</picture>
            </format>
            <validate>
               <picture>A9999</picture>
            </validate>
            <?templateDesigner ScriptInitializers exit::lang=JavaScript;?>
            <event activity="exit">
               <script contentType="application/x-javascript">var ProjectNo=this.rawValue;
var subSection = ProjectNo.substring(1,0);
if(subSection == "R"){
//good
} else if(subSection == "D"){
//good
} else if(subSection == "G"){
//good
} else if(subSection == "S"){
//good
} else if(subSection == "C"){
//good
} else {
xfa.host.messageBox("Value in this should start with one of R, D, G, S, C");
}</script>
            </event>
         </field>
         <?templateDesigner expand 1?></subform>
      <proto/>
      <desc>
         <text name="version">8.0.1291.1.339988.308172</text>
      </desc>
      <?templateDesigner expand 1?></subform>
   <?templateDesigner DefaultLanguage FormCalc?>
   <?templateDesigner DefaultRunAt client?>
   <?templateDesigner Grid show:1, snap:1, units:0, color:ff8080, origin:(0,0), interval:(125000,125000)?>
   <?templateDesigner Zoom 86?>
   <?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?></template>
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
   <agent name="designer">
      <destination>pdf</destination>
      <pdf>
         <!--  [0..n]  -->
         <fontInfo/>
      </pdf>
   </agent>
   <trace>
      <area name="font" level="1"/>
   </trace>
   <present>
      <!--  [0..n]  -->
      <destination>pdf</destination>
      <pdf>
         <!--  [0..n]  -->
         <fontInfo>
            <embed>1</embed>
            <subsetBelow>100</subsetBelow>
         </fontInfo>
         <version>1.65</version>
         <creator>Adobe LiveCycle Designer 8.0</creator>
         <producer>Adobe LiveCycle Designer 8.0</producer>
         <scriptModel>XFA</scriptModel>
         <interactive>1</interactive>
         <tagged>1</tagged>
         <compression>
            <level>6</level>
            <compressLogicalStructure>1</compressLogicalStructure>
            <type/>
         </compression>
         <linearized>1</linearized>
         <batchOutput/>
         <encryption>
            <encrypt/>
            <permissions>
               <accessibleContent>1</accessibleContent>
               <contentCopy>1</contentCopy>
               <documentAssembly>1</documentAssembly>
               <formFieldFilling>1</formFieldFilling>
               <modifyAnnots>1</modifyAnnots>
               <print>1</print>
               <printHighQuality>1</printHighQuality>
               <change>1</change>
               <plaintextMetadata>1</plaintextMetadata>
            </permissions>
         </encryption>
         <openAction>
            <destination/>
         </openAction>
         <taggedMode/>
         <viewerPreferences>
            <addViewerPreferences/>
            <duplexOption/>
            <numberOfCopies/>
            <pageRange/>
         </viewerPreferences>
         <silentPrint>
            <addSilentPrint/>
            <printerName/>
         </silentPrint>
         <renderPolicy/>
      </pdf>
      <common>
         <template>
            <relevant/>
            <base>C:\Documents and Settings\5469\My Documents\</base>
            <uri/>
         </template>
         <data>
            <uri/>
            <adjustData>1</adjustData>
            <xsl>
               <uri/>
            </xsl>
            <outputXSL>
               <uri/>
            </outputXSL>
         </data>
         <messaging/>
         <log>
            <to>uri</to>
            <uri>C:\DOCUME~1\5469\LOCALS~1\Temp\_c7k18f7p4a1d33r1n.log</uri>
            <mode>overwrite</mode>
            <threshold/>
         </log>
         <locale/>
      </common>
      <xdp>
         <packets>*</packets>
      </xdp>
      <cache>
         <renderCache/>
      </cache>
      <incrementalMerge/>
      <script>
         <runScripts/>
         <exclude/>
      </script>
      <pagination/>
      <copies/>
      <layout/>
      <output>
         <to>uri</to>
         <uri>C:\DOCUME~1\5469\LOCALS~1\Temp\_c7k18f7p4a1d33r1n.pdf</uri>
      </output>
   </present>
   <acrobat>
      <acrobat7>
         <dynamicRender>forbidden</dynamicRender>
      </acrobat7>
      <common>
         <locale/>
         <data>
            <uri/>
            <adjustData>1</adjustData>
            <xsl>
               <uri/>
            </xsl>
            <outputXSL>
               <uri/>
            </outputXSL>
         </data>
         <template>
            <relevant/>
            <base>C:\Documents and Settings\5469\My Documents\</base>
            <uri/>
         </template>
      </common>
   </acrobat>
   <psMap/>
</config>
<localeSet xmlns="http://www.xfa.org/schema/xfa-locale-set/2.1/">
   <locale name="en_US" desc="English (United States)">
      <calendarSymbols name="gregorian">
         <monthNames>
            <month>January</month>
            <month>February</month>
            <month>March</month>
            <month>April</month>
            <month>May</month>
            <month>June</month>
            <month>July</month>
            <month>August</month>
            <month>September</month>
            <month>October</month>
            <month>November</month>
            <month>December</month>
         </monthNames>
         <monthNames abbr="1">
            <month>Jan</month>
            <month>Feb</month>
            <month>Mar</month>
            <month>Apr</month>
            <month>May</month>
            <month>Jun</month>
            <month>Jul</month>
            <month>Aug</month>
            <month>Sep</month>
            <month>Oct</month>
            <month>Nov</month>
            <month>Dec</month>
         </monthNames>
         <dayNames>
            <day>Sunday</day>
            <day>Monday</day>
            <day>Tuesday</day>
            <day>Wednesday</day>
            <day>Thursday</day>
            <day>Friday</day>
            <day>Saturday</day>
         </dayNames>
         <dayNames abbr="1">
            <day>Sun</day>
            <day>Mon</day>
            <day>Tue</day>
            <day>Wed</day>
            <day>Thu</day>
            <day>Fri</day>
            <day>Sat</day>
         </dayNames>
         <meridiemNames>
            <meridiem>AM</meridiem>
            <meridiem>PM</meridiem>
         </meridiemNames>
         <eraNames>
            <era>BC</era>
            <era>AD</era>
         </eraNames>
      </calendarSymbols>
      <datePatterns>
         <datePattern name="full">EEEE, MMMM D, YYYY</datePattern>
         <datePattern name="long">MMMM D, YYYY</datePattern>
         <datePattern name="med">MMM D, YYYY</datePattern>
         <datePattern name="short">M/D/YY</datePattern>
      </datePatterns>
      <timePatterns>
         <timePattern name="full">h:MM:SS A Z</timePattern>
         <timePattern name="long">h:MM:SS A Z</timePattern>
         <timePattern name="med">h:MM:SS A</timePattern>
         <timePattern name="short">h:MM A</timePattern>
      </timePatterns>
      <dateTimeSymbols>GyMdkHmsSEDFwWahKzZ</dateTimeSymbols>
      <numberPatterns>
         <numberPattern name="numeric">z,zz9.zzz</numberPattern>
         <numberPattern name="currency">$z,zz9.99|($z,zz9.99)</numberPattern>
         <numberPattern name="percent">z,zz9%</numberPattern>
      </numberPatterns>
      <numberSymbols>
         <numberSymbol name="decimal">.</numberSymbol>
         <numberSymbol name="grouping">,</numberSymbol>
         <numberSymbol name="percent">%</numberSymbol>
         <numberSymbol name="minus">-</numberSymbol>
         <numberSymbol name="zero">0</numberSymbol>
      </numberSymbols>
      <currencySymbols>
         <currencySymbol name="symbol">$</currencySymbol>
         <currencySymbol name="isoname">USD</currencySymbol>
         <currencySymbol name="decimal">.</currencySymbol>
      </currencySymbols>
   </locale>
</localeSet>
<PDFSecurity print="1" printHighQuality="1" change="1" modifyAnnots="1" formFieldFilling="1" documentAssembly="1" contentCopy="1" accessibleContent="1" metadata="1" xmlns="http://ns.adobe.com/xtd/"/></xdp:xdp>

Avatar

Level 2

Professor,

this works!  I might play around with it some more and come up with further questions, but your code works!

Thanks again!

Markus   

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----