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

Date validation in Livecycle / acrobat pro

Fhomasp
Registered: Sep 24 2008
Posts: 4

Hey,

I have made a pdf form using Livecycle designer. All went well until I started to work on field validation.
First problem was the default Livecycle Datevalidation interface. It allows me to only check for one dateformat and if that format is wrong, a usermessage gets printed but the wrong value remains set in the field!

Then I thought about javascripting it but that doesn't seem to work very well.

There are a number of global functions I want to specify and I want to check the fields during exit of such a field and when the user attempts to save the form.

I can't seem to find a means to get global (document level) javascript into the form. Not with Livecycle nor with acrobat pro.
In Acrobat Pro there's a possibility (advanced -> document processing -> document javascript) but that option is always grayed out. I can only access the javascript debugger.

I'm using livecycle designer es 8 and Acrobat pro extended 9.

Need any info, just ask.

Thanks in advance.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
LiveCycle Designer builds XML forms that are converted into PDF. Because of this there isn't a concept of Document Scripts. The PDF is just a shell that holds the XML form. Now it's true that the PDF shell does have document level scripts, but when a LiveCyle form is loaded into Acrobat it shuts down all the Acrobat features that are incompatible with a LiveCycle form.

As for validation, JavaScript should work fine. What was the problem you had?

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

Fhomasp
Registered: Sep 24 2008
Posts: 4
Well,

Here are more specific questions.

How do I build checks when attempting to save a pdf form? Date Validation is a rather big method, how can I get this to work properly without having to fall into the redundency of writing the method on every Date field handle?

In the designer I can also specify validation, but more than just a message of improper formatting seems harder than expected. I put in an invalid value in a datefield which gives me an error message but it still keeps the value in the field.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If you are using a date field then the user doesn't need to enter a value. They just select it off of the popup, so in a way validation is a moot point.

Unfortunately it doesn't seem that you can block the user from entering something manually, and if you use the validation pattern you are stuck with the default functionality. So the only "official" way to go is to use a script.

But there is trick, the "change" event can be used to block manual user input with this script.

if(xfa.event.change.length == 1)
xfa.event.change = "";

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/]http://www.adobe.com/devnet/acrobat/[/url]

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

Fhomasp
Registered: Sep 24 2008
Posts: 4
Hey,

I should have specified an important requirement.
The idea is that people with a disabilty can fill in the form using various means of special input devices. For ex. blind people have this braille reading device which translates everything to its text form. Obviously a popup with datepicker is for that reason out of the question as only means for input.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok then, I don't think you have any choice except to write a validation script. Write the script as a function and place it in a document level scripting object. That way, you only have to place the call to the function in the validation script.

You might also be able to use a change event script to help the user along with the input format.

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/]http://www.adobe.com/devnet/acrobat/[/url]

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