3 Replies Latest reply on Jun 10, 2009 12:38 PM by gkaiseril

    charLimit property on field object

    bulk88

      How can I uncheck/turn off the "Limit of X Characters" from Javascript? the value of field.charLimit is '0' if you get it, but if you try to set it to 0 or '' (empty string), you get a "RangeError: Invalid argument value". I also tried "delete getField('myField').charLimit;" it returns true, but the getting charLimit still has it be the 1-1000000000 value, not 0, how can I uncheck the charLimit through javascript?

        • 1. Re: charLimit property on field object
          gkaiseril MVP & Adobe Community Professional

          You can not.

           

          Have you considered using a 'custom keystroke' and 'custom format' scripts so you can dynamically change this property using the 'setAction' method of the field object?

          • 2. Re: charLimit property on field object
            bulk88 Level 1

            I'm trying to convert a field from comb to not a comb inside a format event and vice versa. "getField('myField').comb = false; getField('myField').doNotScroll = false; getField('myField').charLimit = 0;" would be the logical way since getting charLimit when its unchecked is 0. The easiet thing to do is to set charLimit to 1000000000 but it seems the dirty way to do it, but it will work fine for my purpose.

             

            I've considered removing the field, then adding it and rebuilding it in JS (ex. "myFieldRect = getField('myField').rect; doc.removeField("myField"); doc.addField("myField", "text", 0, myFieldRect);", but it seems like a very long way to get it done the clean way . I'm not sure if this charLimit problem is a bug or not with Acrobat Javascript. Inside Foxit Reader 3.0, setting charLimit = 0 will not produce an error and it removes the limit. But Foxit Reader  doesn't speak for the PDF spec or Acrobat.

            • 3. Re: charLimit property on field object
              gkaiseril MVP & Adobe Community Professional

              I have no problem with a comb field created in Acrobat 8 Professional and opened in Foxit Reader 3.0.

               

              It is always better to edit the form in Acrobat than trying to do it through JavaScript.