Microsoft
Software
Hardware
Network
Question : Acrobat date field defaults to Today only if blank
The goal is for a brand new Acrobat form to fill a field with Today's date when the user opens it. If the user saves the form as is and opens it a few days later, the old date will still be there, not replaced by the current date. If the user changes date in the field, that date will be saved and will not be replaced when the form is opened later.
So we need a date field that:
1. Defaults to Today's date when the form is opened, but only if the field is empty.
2. Allows entering and saving a date different from Today.
3. When the form is reopened, it will not replace an existing date entry with Today's date.
I have a Custom Calculation Script for a date field that does all of this, but with one problem:
if (event.value != "")
then
event.value = util.printd ("m/d/yyyy", new Date())
endif
It is not clear to me why the if / then condition works. But it does work to enter Today's date when the Field dialog is closed or when a value is deleted from the field. And it works to allow the user to enter and save a date different from Today. Without the if / then condition, the user cannot enter a different date - it is always overwritten with Today.
The problem is that I cannot save this Acrobat form with no date in the field. That needs to happen so that the field will fill with Today's date when the user opens the form.
When finish entering the formula, the script dutifully puts Today's date in the field. If I delete the date, it fills back in. So today's date is saved in the field when the form is saved. Consequently, when a user opens the form later, the field does not default to Today. Instead, it has the date I saved the form.
I think the answer may be to enter a script as a Document JavaScript (Advanced | Document Process | Document JavaScripts), since Document scripts execute when the form is opened, but I have been unsuccessful in devising a script that does an if / then based on a blank date field. I don't see how to test for an empty date field, having tried:
== null
= ''
Thank you in advance for your help.
Answer : Acrobat date field defaults to Today only if blank
A Document Javascript does the trick:
var f = this.getField("MeetingDate
");
if (!f.value) f.value = util.printd("m/d/yyyy", new Date());
Random Solutions
How to install XP with F6 driver requirement and no floppy
Oracle Forms 10 Master/Detail not displaying detail if all items are "display"
ftp put via php from linux to AS/400
Mitel Teleworker One Way Audio
.NET framework error on install
How to trace a phone without installing the software?
How to determine hard disk activities
Nokia E52 Language
JMS servers in weblogic
Editing the Windows Message "Your Account has Expired. Please contact your system administrator" for Windows XP Professional