I’m creating a form in Adobe Acrobat Standard 9. I have 4 check boxes on it. I want to require the user to select at least one, but the user can select more than one also.
The form has a Submit button that emails the form as a pdf.
What I want to do is when the user clicks the submit button, validate that at least one of the check boxes is checked. If not, do not allow the email and display an error message. I am new to Java Script and need exact code and instructions. Thanks!
1. Create a 'required' text field behind your check boxes with white text (hopefully your background is white).
2. Add a calculation to the new text field to only include a value in it if one of the check boxes is marked:
var cb1 = this.getField("Check Box1").value;
var cb2 = this.getField("Check Box2").value;
var cb3 = this.getField("Check Box3").value;
var cb4 = this.getField("Check Box4").value;
if (cb1 == "Yes" || cb2 == "Yes" || cb3 == "Yes" || cb4 == "Yes"){this.getField("text field").value = 1;}
else {this.getField("text field").value = "";}
If one of the boxes is checked, the new required text box should be filled and satisfy the 'required' field.
3. Add the following Mouse Up/Run a Javascript action of the submit button (not using the Acrobat Submit menu):
var tf1 = this.getField("text field").value;
if (tf1 == 1){this.getField("text field").display = display.hidden;}
else {this.getField("text field").display = display.visible; app.alert("You forgot something.");}
this.submitForm("mailto:user [at] domain [dot] com");
STEVE MITTEL
Senior Forms Designer
Texas Comptroller of Public Accounts