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

New to Acrobat...newer to JavaScript...please help.

JavaScriptNoob
Registered: Feb 12 2010
Posts: 8

Hi Forum,
I am new to the site and I think I am also in over my head a little.
I have never used JavaScript before and I really need help figuring out if what I want is even possible. What I was hoping to do with my form (in Acrobat 9 pro) was prevent users from printing it until it had all the required fields populated (of which there are about 15). I have the fields set to “required” but a user can still print the form even if it’s blank or partially filled out. There will NOT be an online submission aspect to the form as it needs to be signed after it’s printed and manually submitted to the HR department.

So my question is, aside from the popup error message that I have put in when they leave a required field blank, can I stop them from printing the form until its finished?. Any help would be greatly appreciated.

OH this is the script that I found on the Forum that causes the popup. That might need some tweaking too… But again if anyone can help I would be SO grateful!

if(/^\s*$/.test(event.value))
app.alert("This field is mandatory, please complete.");

My Product Information:
Acrobat Pro 9.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
No you can not, but you can mark the form as incomplete through the use of a read only form field.

You might want to start looking at the tutorials, articles, and eseminar's on demand on this site.

George Kaiser

JavaScriptNoob
Registered: Feb 12 2010
Posts: 8
Oh, marking it incomplete might actually help! Is that something that goes away after they do it right?
Will I find the proper way to do that here in the forums?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You script will control the display or hiding of the field so when your script is satisfied that the form is complete, the text can be hidden or removed. And you should also check to make sure that if a required field is cleared the text is displayed or shown.

You will learn how to write a document level function and show and hide a field. But depending upon how you chose to test for 'required' fields will determine how your script works.

George Kaiser

JavaScriptNoob
Registered: Feb 12 2010
Posts: 8
Thank you gkaiseril, all I have now is the popup alert that basically tells the user that they did not enter a value, but only if they clicked in the field at all... So it’s not good enough as it is now.

Can I get it to run a script to do validation check with the document will print event? Can you give me an example of what this might look like?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You need to place your validation script in the document's "WillPrint" event.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

JavaScriptNoob
Registered: Feb 12 2010
Posts: 8
Thank you Try67. I would love to know how to do that…the code part anyway. I do know how to navigate acrobat but the code is my problem.
I have been searching everywhere for an example of what a validation script looks like or how to start one and I am not having any luck. And the tutorials I have found are not addressing my issue either. I really like Acrobat 9 pro, I was able to create a great form, but without some sort of validation process in place it’s almost useless. It’s too bad you need to know how to write code to do it! LOL

Do you or anyone else know where I can find the right resource for a JavaScript novice? I need to get this form out to our department ASAP and this is the only part holding me up (albeit it’s a big part). Even if someone could give me a basic (or detailed if you have the time) example of what it might look like. To give you a better idea of what I need validated (and by validated I really only need it to see if the user has entered a value in the field or not, so no calculations or color changes needed) I am requesting things like “Department” “Division” “Manager’s Name” “Phone Number” and I even a few radio buttons with choices for users to select one.

Thanks again! I really appreciate your patience.