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

Validating Checkboxes

jayyy91
Registered: Mar 11 2009
Posts: 13

Hi,

I was wondering if I could validate checkboxes to make sure that required checkboxes are checked when the user submits a form. The checkboxes that are required are Yes and No checkboxes so one of them must be checked by the user when they submit the form. Obviously I have given them the same name so that only one can be checked at a time. I know radio buttons can have this done but the reason I have checkboxes instead of radio buttons is because when I ran Form Field Recognition, it automatically filled all my boxes with checkboxes. So unless there is a way to run Form Field Recognition and have it fill my boxes with radio buttons, then I will need the checkboxes to be validated.

Thanks.

My Product Information:
Acrobat Standard 9.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you can validate check boxes, but you have to do it with a submit script, instead of using a simple submit button.

However, why not just delete the check boxes and replace them with radio buttons.

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]

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

jayyy91
Registered: Mar 11 2009
Posts: 13
Thank you for your answer. The reason I don't want to replace the checkboxes with radio buttons is because there are a lot of them and it will take a lot of time to do and the checkboxes are already named.

I have no experience with script so will you be able to show me an example that I could learn from? Or is it really complicated?

Thanks.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I was afraid that was going to be your answer.

The script isn't too bad, but you do have to be able to do a little coding. Here's a couple of articles on scripts for submitting data.

http://www.acrobatusers.com/tutorials/dynamically-setting-submit-e-mail-address

http://www.acrobatusers.com/tutorials/2006/submitting_data

The trick for your script, is to test all the fields you're interested in and then, only if everything is right, to call the submitForm function.

Like this:
var cErrMsg = ""; var myChkVal = this.getField("MyCheck").value;if(myChkVal == "Off")cErrMsg += "Required Field 'MyCheck' is not filled out\n"; /* Repeat test for all check box groups */ if(cErrMsg.length)app.alert(cErrMsg);elsethis.submitForm(...);

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]

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