Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

manually created submit buttons & mandatory fields

Avatar

Level 3

Hi,

I included a Submit & an Email button in some of my forms.  I've set them up as Regular buttons and coded them myself to do what I want eg:

if(xfa.host.messageBox("Please save this form before emailing or data will be lost","Save Form",1,1))
    app.execMenuItem("SaveAs");
   
var sEmail = form1.Pg2.PtESF.Mgremail.rawValue;
var sSubject = ("Permit to Train Request by " + form1.Pg1.PtASF.FirstNameFld.rawValue + " " + form1.Pg1.PtASF.LastNameFld.rawValue);
var sBody = "Please approve the Permit to Train Request as attached.";


event.target.submitForm({cURL:"mailto: "+ sEmail +"?subject=" + sSubject +"&body=" + sBody,cSubmitAs:"PDF",cCharset:"utf-8"});

If I set them up as Submit buttons, they don't try to run the script more than once.  I assumed this was because I had the code built in with the Submit option and it ran that as well as my own code.

So I changed the button to be a Regular button and then it worked perfectly - except for one thing.

It no longer validated the mandatory fields.

Can anyone tell me what's built into the Submit button (that I can't see), that I need to reproduce in my script for my regular button?

Thanks,

Peta

2 Replies

Avatar

Level 10

Hi,

The Submit buttons validate the from behind the scenes.

You can use execValidate() in an if statement, and if passes then execute script.

See an example here for execValidate():

http://assure.ly/hM2A5y (see last button)

http://assure.ly/flbjXB

Both of the above examples use validationState and cancelAction so are targeted to Acrobat/Reader version 9.1. Please note that execValidate() can be used in earlier versions:

http://assure.ly/lZhrSS

http://assure.ly/dYQFb4

Hope that helps,

Niall