I have a basic Acrobat form to track volunteer hours. The user enters a start time and end time for each session. The elapsed time field is auto-calculated for each session as well as the page total. Time formatting is "h:MM tt".
Everything works as long as the user enters times in the form "11:00" or "11:00 pm" (default is "am" if no am/pm is entered).
What I've been struggling with is how to allow time entry as "11" or "11 am", which throws errors on the auto-calc. I've tried using Custom Calculation, Validation, Formatting but to no avail.
I've learned a lot in the hours I've spent reading thru the great date/time tutorials in the forum, but am at an impasse.
Any help would be greatly appreciated.
But you could also put in code to do some checking and fix up in the calculation script. Use a regular expression to identify the missing parts of the input and then add in default values.
For example: /(\d{1,2})\:?(\d{1,2})?\s*(am?|pm?)?/i
This regular expression captures all three parts of the time string. And then you can test to find out what's missing.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script