Copy link to clipboard
Copied
Hello,
I would like to know how to automate date and time (military time) based on a previous input. Please refer to the image below.
So, I would like to automate it so that when the shift supervisor has filled out the signature field, both the date and time field will be automatically filled. How can I do that? Please help!
Copy link to clipboard
Copied
What kind of field is your "signature" field? If it's a real Digital Signature then it will contain the current date and time automatically, although it doesn't look like it is. If it's just a text field you can use the field's custom validation script to populate the other fields.
Copy link to clipboard
Copied
try67​
I was somehow able to get it to work using the following script on the "signature" field:
var timeField = this.getField("Time");
timeField.value = util.printd("HH:MM", new Date());
var dateField = this.getField("Date");
dateField.value = util.printd("mm/dd/yyyy", new Date());
However, the problem I have with this is code is that every time the signature field is simply clicked on, the date and time is updates automatically. Even without putting any information on the signature field, the data and time gets updated. I would like to make it so that some sort of information has to be in the "signature" field for the date and time to be update. And, I would like to make sure the date and time field stay fixed once the "signature" field has been filled. Because, as of now, simply clicking on the signature filed updates the date and time automatically.
So, for example:
Once "John Doe" was put his initials in the signature field, the date and time will be automatically updates and will remain fixed. Only when ALL the information in the signature has been erased can be date and time field change.
is there a way I can do this?
Copy link to clipboard
Copied
You're on the right path. I think you placed the code in an incorrect location, though. Move it to be the signature field's custom Validation script, and use this version of it:
var timeField = this.getField("Time");
var dateField = this.getField("Date");
if (event.value=="") {
timeField.value = "";
dateField.value = "";
} else {
timeField.value = util.printd("HH:MM", new Date());
dateField.value = util.printd("mm/dd/yyyy", new Date());
}
Copy link to clipboard
Copied
Wow, thank you very much. This is exactly what I needed.