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

Still can't for "agree to terms" with email submit button...

rwilki
Registered: Oct 16 2009
Posts: 37
Answered

I hope someone can help. I've been all through the forum and around google too.

I have a nice script which I modified from the AcrobatUsers group. But, I need the reader click on a checkbox before they can email the form. Here's my code for the "mouse-up" action of the email submit button, anyone have any ideas?

//
// Before sending the data, make sure that all required
// fields are valid
//
// The "Ex1ValidFields" fucntion is located in the document script
// If you copy this button action then you will also need to delete
// this first if statement or copy the "Ex1ValidFields()"
// function and modify it to work with your form.
//
// This is the form return email, It’s hardcoded
// so that the form is always returned to the same address
// Change address on your form
var cToAddr = "name [at] email [dot] com";

// Get the client CC email address
var cCCAddr = this.getField("SalesRepTarget").value;

// Now get the beneficiary email only if it is filled out
var cBenAddr = this.getField("Benemail").value;
if(cBenAddr != "")
cCCAddr += ";" + cBenAddr;

// Set the subject and body text for the e-mail message
var cSubLine = "Advertising Form Returned from "
+ this.getField("Advertiser").value + " "
+ "c/o " + this.getField("Agency").value;

// Set the body text for the email message
var cBody = "Thank you for submitting your form.\n" +
"Save the mail attachment for your own records";

// Send the form data as an FDF attachment on an email
this.mailForm({bUI:true, cTo: cToAddr, cCc: cCCAddr,
cSubject: cSubLine, cMsg: cBody});

My Product Information:
Acrobat Pro 7.0.8, Macintosh
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
So before the mailForm command you need to get the value of the check-box and test if it's selected.
If not, don't execute mailForm and maybe display an alert to the user.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

rwilki
Registered: Oct 16 2009
Posts: 37
That's exactly what I need to do. Any thoughts? I'm OK with javascript when I see it in front of me, but not writing it from scratch...
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
if (this.getField("checkbox").value=="on") {
this.mailForm(...);
}
else {app.alert("You must agree to the terms by ticking the check box before sending this form.");}

Of course, you will need to change the field's name and "on" value to match yours.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

rwilki
Registered: Oct 16 2009
Posts: 37
try67 your code was perfect. Thank you very very much for your help!