These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Time Validation

eabikhzer
Registered: Jul 8 2008
Posts: 29

Hello,

I have a form (created with Acrobat Pro) which requires users to enter the number of hours worked on a certain project. I want the field to be in HH:MM mode, so I used the Validate - Time format. The problem is that if for example an employee spent 25 hours on a project, the field is not validated since the maximum value possible is 23:59. Is it possible to validate a field with a time but that is not constrained to 24 hours?

Thank You

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, but you'll have to write your own custom KeyStroke script.

24 hour time strings are easy to parse and validate, Try this code
if(event.willCommit){event.rc = /(\d{1,2})\:(\d{1,2})/.test(event.value);if(event.rc){// Test minutes componentsif(Number(RegExp.$2) > 59){event.rc = false;app.alert("Invalid Minute Value");}// Include a test here for the Hours value (RegExp.$1) if needed}elseapp.alert("Invalid 24 hour time value");}

I just wrote a whole section on date/time entry and formatting at www.pdfscripting.com.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
A "time" field is for displaying the time of a single day. The maximum time is 23:59:59.999 and after that one is in the next day. The description for date time field is:
Quote:
A field that accepts and displays date/time data and supports pattern recognition.
And the time field shows the time for a given date and has a raw value of the number of milliseconds from the epoch date.

You solution will be using a text field and writing the entry, editing, display, and validation scripts.

George Kaiser