Forum Moderators: not2easy

Message Too Old, No Replies

JavaScript Validation in a PDF document?

         

kapow

6:16 pm on Jun 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a PDF form that visitors should copy to their computer, complete on-screen, print and post. Have been trying all day to get a validation function working - with no success. I havn't done this kind of thing in a PDF before.

Its a bit different to an html page - I can add input fields but there is no form tag. Can anyone tell me how to get a PDF to display an error message if a certain box hasn't been completed e.g. the address box?

I can do it if I create a submit button and a 'required field' but the message says 'so and so was found empty during export'. - I don't want 'export' to appear, it is misleading. I want a message that I specify to appear if a field is empty or not enough characters in it.

My java script is like this (but it doesn't work).

function validate()
{
submitOK="True";
var message = "Form incomplete, please enter your:\n";

if (document.Address.value.length<10)
{ message += "Address at the top of the form.\n";
submitOK="False"; }

if (submitOK=="False")
{
alert(message)
return false;
}
else
{
return true;
}

}

mivox

7:39 pm on Jun 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using Acrobat's built-in script editor function? Last time I built a self-calculating form, it took me days to sort it out, but I could have sword Acrobat had it's own validation functions built-in...

kapow

12:54 pm on Jun 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you using Acrobat's built-in script editor function?

It tells me which line has an error on it. (My first javascript had the script tag in it as it came from one of my html pages. The Acrobat thing told me there was an error on the first line so I assumed it didn't need that tag and I removed it). Now the script (in my first post) doesn't generate an error but doesn't popup a message either i.e. it doesn't do anything!

I don't need fancy calculations, I just need a basic 'required fields' thing. The PDF doesn't export any info it is meant to be printed and posted after completion (so the 'problem on export' message might worry a user).