Search code examples
javascriptdatepdfacrobat

How to assigning custom date to pdf date field?


I am trying to assign someones birth date to a text field (that has a format catorgery set to a mm/dd/yyyy date format) and am unable to figure out how to correctly assign a date.

When I do the following code I get a "TypeError: this.getField("ctxtBIRTHDATE1") is null"

this.getField('ctxtBIRTHDATE1').value='11/11/1985';

So I did research on the data type and came up with the following code but I still am getting the error.

this.getField('ctxtBIRTHDATE1').value=util.printd("mm/dd/yyyy", new Date('11/11/1985'));

Any ideas on how to properly assign a date would be really appreciated. Thanks.


Solution

  • This error message means that there is no field "ctxtBIRTHDATE1".

    Check your field name's spelling.

    If that still does not eliminate the error, open the field's property dialog, and copy the field name from the according field in the dialog and paste it into your code.

    If that still causes the error, rename the field, and it may even lead to replacing the field.