Skip to main content
October 9, 2019
Question

How can I edit the Format Category of a Text Field Property using Javascript

  • October 9, 2019
  • 2 replies
  • 2721 views

Howdy,

 

I did my best to locate how to edit a text field property via javascript in this guide:

https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_developer_guide.pdf

 

My situation: 

Currently, I am using javascript to copy each field in a pdf, copy all of its attributes under a new name, and replace the old field. (Thanks to the way copying a field works. IE it keeps the same name and entering information into the original field duplicates that data into the copied fields as well. Cannot manually change the names of 500+ fields daily..) I got the script to run great with one problem. Text Fields can have a format category of "Date," and I cannot seem to figure out how to set this attribute when I create the object via javascript (the fields dont have the calendar option to the right of them, they are just regular text boxes).

 

Example of what I am looking for:

var f = this.addField("coolname", "text", 0, [200, 250, 250, 400]);

f.format = "date";

 

Hope this was clear, thanks for the help!

 

 

    This topic has been closed for replies.

    2 replies

    ls_rbls
    Community Expert
    Community Expert
    October 10, 2019
    October 10, 2019
    So I am not trying to actually input a date, nor am I trying to copy a date from another date field. I am attempting to create a field that is set with the date format. So later another user can input a date into that field via the calendar.
    ls_rbls
    Community Expert
    Community Expert
    October 10, 2019

    Ooooh! ok that is too easy. just select date field add it to your document like you would for a text field. You can also add a text field and in the field Properties go to the Format tab and select from the pulldown DATE. You can choose any of the pre-selected date formats that are listed there or provide a custom date format. So when your user inputs a date, like for example, let's say he/she types in "9sep" and hit enter it will adjust automatically and complete the date using the format that you specified for that field; the same will happen if the user choose a date from the date picker... I think this is what is referred to arbitrary masking (someone please correct me if I am wrong)