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

javaScript for a checkbox

Elya42
Registered: Mar 3 2009
Posts: 59

this what I need to do: Run a validation script for a checkbox, with the following information

If the score in "Yes6.1" [a text box within the PDF] is less than 70% then the checkbox cannot be checked and a app.alert opens explaining why the action cannot be completed.

I know that within the properties, of the checkbox, I select the "Actions" tab and then select "run a JavaScriopt".

I just cannot get the script right. Can anyone help, it would be greatly appreciated and perhaps I will stop having checkboxes attacking me in my nightmares.

Elaine M

My Product Information:
Acrobat Pro 9.1, Macintosh
j_shell
Registered: Nov 16 2007
Posts: 25
This should work for you. You will need to change the field name in the resetForm area. You may also need to change the .70 to work with the value you have.
var a = this.getField("Yes6.1"); if (a.value < .70) {this.resetForm("checkBox1");app.alert("Insert message here!");}

Justin
Elya42
Registered: Mar 3 2009
Posts: 59
message in JavaScript Debugger - this.resetForm is not a function

Elaine M

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Interesting! Are you working with an AcroForm or a LiveCycle form? What event are you running this code from?

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

Elya42
Registered: Mar 3 2009
Posts: 59
Acrobat 9pro - in a checkbox - Actions - Mouse Up - Run a javaScript

Elaine M

j_shell
Registered: Nov 16 2007
Posts: 25
Hmmm.... I haven't seen that before. Try posting all of the code here. It's easy to glaze-over when you have looked at something too many times. Maybe we will see something new.
Elya42
Registered: Mar 3 2009
Posts: 59
The Cod is located in - the checkbox properties - in Actions - Mouse Up - Run a javaScript

var nSumVal=this.getField("Yes6.1").value;
event.rc= (nSumVal >=.70);
if(!event.rc)
app.alert("Action not Permitted - score under 70%")

Elaine M

j_shell
Registered: Nov 16 2007
Posts: 25
Looks like Thom has answered this in the JavaScript forum.