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

Validate Radio Button

HLF
Registered: Jan 6 2008
Posts: 21
Answered

Easiest question of the day.

I have a single group of radio buttons. The initial setting for all is unchecked.
Before invoking the print script I want to create an app.alert if the radio button group is not checked. Otherwise continue to print.

Thank you.

HLF

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
In AcroForms you can check for the value of the radio button group for a value of "Off".

George Kaiser

HLF
Registered: Jan 6 2008
Posts: 21
Thank you George. As a "newbie" this is helpful but not quite enough.
My button group is called pay.

I write

var test = thisgetField("pay")

to check that this is correct I write

app.alert(test.value)

and I am pleased to see that "Yes" and "Off" appear appropriately for selected and none selected.

I have been unable to get to write the "if-then" statements correctly such that when the value if "Off" an app.alert message is created and exits but when the value is "Yes" the print routine runs.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You can use:

var test = this.getField("pay")
if (test.value == "Off") {
app.alert("No button selected", 1, 0);
} else {
app.alert("You selected the button with an export value of " + test.value, 3, 0);
}

You should also have each button in a group have a unique export value so you tell which button was selected by the value of the field.

George Kaiser

HLF
Registered: Jan 6 2008
Posts: 21
Thank you very much.

HLF