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

Make Check Box Mandatory before submittion

mawilde
Registered: Jun 9 2008
Posts: 6

Hi There,

I'm a new user, so be gentle!

I have created a form with a check box required to indicate the recipient accepts conditions of business. However, I can't seem to make this check box mandatory before submission i.e. the user can still submit the form even if they have not "checked" the box.

I think I need to use Java Script but don't have a clue where to start, please help.

M

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Since check boxes are either on or off, the ordinary concept of "Required" doesn't fit. There's no way for Acrobat to determine whether the On or Off value is correct, at least not for an AcroForm. LiveCycle forms are a little different.

So yes, you need to use a script for both the checking and the submission.

Here's an example for a check box named "MyCheck". Place this code in a "Run a javaScript" action on the submit button. Remove all other actions.

if(this.getField("MyCheck").isBoxChecked(0))
this.submitForm(...);
else
app.alert("You must read and accept terms before submitting");

You can read about the "submitForm" fucntion here.

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/submitting_data/

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

mawilde
Registered: Jun 9 2008
Posts: 6
Hi Thomp,

Sorry for being thick, but I have zero knowledge of Java Script, so if you can be bothered, it would be great if you could make your answer idiot proof.

1) Is it a standard button I add to the form?
2) If yes, should the "Control Type" on the "Field" tab be "Submit"?
3) Do I type the script you provided directly into the "Submit to URL" field on the "submit" tab?
4) What option do I select in the "Submit As" drop down list (XDP,PDF,XML,HTTP Post)?
5) What is the precise syntax to "Run a Java Script"?
6) Can I then use the "Submit Form" script which was contained in the link you provided to specify the e-mail recipients, subject etc?

I suspect I am a little out of my depth here, but any help would be gratefully received.

M
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ok, you asked this question on the wrong forum. You are building a LiveCycle form and should have asked on the LiveCycle forum. This is vital information for answering the question. Ignore my previous response.

This is a question that has been asked many times and there are several answers, all of them will work. Here is my favorite:

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=13904

be sure to also include a validation message.

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

mawilde
Registered: Jun 9 2008
Posts: 6
Brilliant,

That worked a treat and was very easy. Apologies for the confusion.

Can I still use the Java Script to define the e-mail recipients and send as a PDF rather than XML data?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you have a couple of different options.

1. If you use JavaScript for submitting the form, then you have to also use JavaScript for the required test since the LiveCycle "nullTest" won't automatically stop the submit.

The code for this is very similar to the code I gave in the first response above. You have to modify the the code to acquire the value of the checkbox using the LiveCycle syntax and replace "this" with "event.target". Otherwise the code is the same.

2. If you use the LiveCycle submit button, then the "nulltest" will work to block the submit. To change the email addresses programatically you have to Put a script on the MouseDown event that will modify the fields XML, which is were the email addresses are.

Set up a submit button with an email address. Select it and switch the LiveCycle Designer view to "XML". You should see all the underlying XML that defines the button. In there somewhere is the submit action, where you'll find both the node/property that needs to be modified to change the email, and the node/property that defines the submit type.

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

angergoggles
Registered: Jan 2 2011
Posts: 1
thomp wrote:
Ok, you asked this question on the wrong forum. You are building a LiveCycle form and should have asked on the LiveCycle forum. This is vital information for answering the question. Ignore my previous response.This is a question that has been asked many times and there are several answers, all of them will work. Here is my favorite:

http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=13904

be sure to also include a validation message.
The URL to the solution that was suggested is no longer valid. Here is the posting....

Quoting thomp:

Since the checkbox is a binary value, it's not typically considered something you'd make requred, and the "Required" option is not provided. You have to edit the XML to put the option in.

First though, in the "Options->Binding" tab for the checkbox, delete the "Off" value, so that "off" for the check box is a null value.Next, add a text field to the document and make it required. With the text field selected switch to the XML view. Scroll down to the bottom of the text feild tab and you'll see an entry for the "validate" event. It'll have a "nulltest" property. Copy this line to the same location in the checkbox's field tag. Switch back to design view and accept the changes. Now delete the text field you created.That's it. When the user tries to do the submit they'll get the checkbox flagged and highlighted as required, just like the other required fields.