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

JavaScript assistance for HTML validation

msam
Registered: Mar 22 2010
Posts: 2

Hello,

I have a form that will be rendered either as a PDF Form or an HTML form. I have all the script working fine for the PDF version but am stuck with field validations for the HTML form.

I have 2 fields, one that is a Postal Code (Canadian) and one that is a Phone Number. How do I set up the script so that on the Exit event of these fields, it determines if the value is correct or not?

Any assistance would be greatly appreciated.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This forum is all about Scripting in the PDF environment, so you won't find anything here on HTML scripting. However, HTML JavaScript happens to be about 10,000 more popular than PDF scripting so there is literally tons of info out there on HTML scripting topics. For example, I googled "HTML form validation" and found this page (amoung many thousands of hits):

http://webdesign.about.com/od/forms/a/aa031599.htm

there isn't an exit event in HTML. Validation is typically done on submit. I don't know what you would do for a form rendered to both HTML and PDF, But to find out I would render the XFA as HTML, and then look at the structure of the document and format for the submit button. The structure should parallel the XFA structure. I would also think that scripting objects would convert into script sections. But this is the kind of thing you'll need to find out to be able to script for both HTML and PDF.

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]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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