Copy link to clipboard
Copied
Is there a way to allow various time formats into a "Time" field but have the field contents display HH:MM?
Using the Format tab of the field's Properties, it seems to allow only one format, but the PDF users want more flexibility. Specifically, to input with or without a comma, but output in the field with a comma.
Thanks.
Copy link to clipboard
Copied
Yes, but you'll need to write a custom validation (and possibly also keystroke and format) script to do it.
Copy link to clipboard
Copied
Thank you for your thoughts on the matter. I know that some scripting is needed.
I've written a validation script and attached it to the "Properites >Validate" tab, which allows HH:MM, HHMM, hh:mm, or hhmm
But I can't figure out how to format the output to always be HH:MM
For this second part, I thought maybe a script in "Properites > Calculation" or "Properites > Format" to do the following
(1) get field value
(2) strip out non digits
(3) set field to date format of HH:MM
For example
var enteredTime = getField("TimeField").value;
var numberPattern = /\d+/g;
var extractNum = enteredTime.match( numberPattern );
event.value = (util.printd("HH:MM", extractNum));
But it does not work. I am not familiar with JavaScript or Regular Expressions, so maybe I'm doing something wrong. Or maybe I'm not using the "util.printd" function properly. I'm lost.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now