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
Binary data
how can i get the location of some body by his mobile number or computer IP?
Remove security from MS Access Database (Jet Engine)
Task Scheduler Windows 2008 Server performs task but stays stuck on running. Will this affect the next time the task runs?
Migrating from Lotus Notes to Mac Email Client
Library module to process RAW camera files?
Remote access VPN via Thompson TG585 v7
Why are pointers efficient?
OpenDNS some need full access
How do I add a * (asterisk) as a reg binary value for the Reg Add command