Question
How to create a form with a date field that changes automatically according to the current date?
Answer
Currently, there is no option to create a form with a date field that changes automatically according to the current date.
As a workaround, a Text Field can be created with an assigned JavaScript Button:
- Launch PDF Editor.
- Create a fillable form or open an existing fillable form, and navigate to the Form Editor tab in the menu bar.
- Add the Button for the creation of the current date field. If there is no text field for the date in the fillable form, please create a new Text Field. As a result, a Text Field and a Button in the form is created.
- Right-click on the Button > Properties.
- Go to the Actions tab. Click the Create button.
- The Trigger Event can be set as Click, Action as Run JavaScript.
- In the field for the script, the following code can be used:
var today = new Date(); getField("TextField 1").value = today.toLocaleDateString()
Note: "TextField 1" is the name of the field for the date displaying. If the name of the text field is different (for example, Date), this value should be changed in the code accordingly.
- Enter the script, click Save, and then OK.
- Go back to the Document tab.
- Click the created button to receive the current date in the corresponding text field.
Comments
0 comments
Please sign in to leave a comment.