Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto date/time field fill when another field is filled in

New Here ,
Jan 06, 2020 Jan 06, 2020

Per the title, I'm looking for a way to automatically add the date and time to a field at the moment another field is filled in.  I don't want to use stamps or signatures as i'd like to export these forms to excel in the future to log the data. Bit hard to explain but for example: User A enters initials in "IN1" field, as soon as they fill and exit the field, the date and time that the change was made is entered into a date/time field (ts1) to the right.  


I know this has to be done with a javascript, and I've got one that I believe should be working but I can't figure out how to get it running.  Script below:

 

// Declair Variables
var initials, timeStamp;

// Assign Variables
var initials = IN1
var timeStamp = ts1

if (timeStamp.value == null) {
if (initials.value != null) {
var d = Date(Date.now());
var ds = d.toString()
timestamp = ds.slice(1,24)
}
}

 

Thanks in advance!

TOPICS
How to , PDF forms
5.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Jan 06, 2020 Jan 06, 2020

Place the code for setting the timestamp into the Validate event script for the "Initails" field. 

Something like this

 

this.getField("ts1").value = util.printd("dd:mm:yyyy:HH:MM:ss",new Date);

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2020 Jan 06, 2020

Place the code for setting the timestamp into the Validate event script for the "Initails" field. 

Something like this

 

this.getField("ts1").value = util.printd("dd:mm:yyyy:HH:MM:ss",new Date);

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 14, 2020 Jan 14, 2020
LATEST

That did the trick, thanks!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines