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

Abort submit

Runolfr
Registered: Oct 1 2008
Posts: 119
Answered

I have some code that runs in the preSubmit event of my submit button (a standard Button with a control type of "submit" and a "mailto:address [at] company [dot] com" URL). It pops up a box asking if the users want to continue when they click Submit.

The problem is that it doesn't actually keep the form from submitting if the user clicks "No". How do I abort the submit event if the users chooses "no" when asked to verify submission?

The code...

// Validate before continuing
if (ReferralRequestForm.execValidate() == true) {

// Verify submission
var cMsg = "Are you sure you are ready to submit this form? \n\n"
cMsg += "Select YES to LOCK the form and generate the email.\n\n"
cMsg += "Do you want to Continue?\n\n"
var nRtn = app.alert(cMsg,1,2, "Lock Form?");

if(nRtn == 4)
{ // A Yes Answer
// .access property of controls set to "protected"

}
endif; // alert "Yes"

}
endif; // form validates

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You can't stop the submission from the PreSubmit event. I know it seems like this is something you aught to be able to do, but Adobe missed this one.

If you want to control submission you have to do it all in script using the legacy AcrobForm submit function.

Make a regular button and place you PreSubmit code in it. To do the actual submit use code like this.

event.target.submitForm(...);

I didn't include any submit form parameters, you'll need to fill in your own. Take a look at the article for more information.

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/submitting_data/

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/]http://www.adobe.com/devnet/acrobat/[/url]

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