Certainly. Use this code as the button's MouseUp script (adjust the field name and date format, of course):
this.getField("CurrentTime").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Thanks for the help, I got it.
I am using this code to generate a name in a textbox, based on their respective names. The name that appears to me in the textbox is: GPDS_ContractName_ Date and Time. I use this to generate the default file name for me. I would like to insert below a
Var v1 = "GPDS_" + getField ("CONTRACT NAME"). ValueAsString + "_" + getField ("TIME") valueAsString
Var v2 = v1.replace ("/", "");
Var v3 = v2.replace ("/", "");
Var v4 = v3.replace (":", "");
GetField ("FILE NAME"). Value = v4;
Your code contains a lot of mistakes... You should spend some time studying the core JS syntax, before writing any code for Acrobat.
But it's working
But how are you populating the time field. If you add a document level script like
this.getField("Time").value = util.printd("mm/dd/yyyy HH:MM", new Date());
The time field will be automatically populated with the system time when the PDF is opened. It is also possible when using the Date object to easily pull the year, month, date, hour, and minutes form a valid date.
If the user is entering the date and time how are you validating that the entered data is correct?
It is also possible that the name could contain the "/" or ":" and then your script might not properly work.