Expand my Community achievements bar.

Dynamic Submit Button- Required Fields

Avatar

Former Community Member

I needed a dynamic submit button that would cc a field from the form.  I found the following script and it works great, but it doesn't give an error message if someone didn't fill in a required field like a regular submit button would. Is it possible to use the script below but to check for required fields?

// This is the form return e-mail. Its hardcoded

// so that the form is always returned to the same address

// Change address on your form

var cToAddr = "909@gideons.org";

// First, get the client CC e-mail address

var cCCAddr = RegionalDirector;

// Set the subject and body text for the e-mail message

var cSubLine = "909 Camp Visitation Report-" + xfa.resolveNode("#subform[0].#subform[7].Country"); var cBody = "Thank you for submitting your 909 report.\n" + "Save a copy for your records";

// Send the form data as an FDF attachment on an e-mail

event.target.mailDoc({

          bUI: true,

          cTo: cToAddr,

          cCc: cCCAddr,

          cSubject: cSubLine,

          cMsg: cBody

});

6 Replies

Avatar

Former Community Member

Hi, I have the same question as the OP and I didn't think that the article linked to answered the question at all. Your link is about how to choopse the email that the form goes to. We want the form to not submit when required fields have been missed, and give an error message.

Can anyone help?

Avatar

Level 10

Hi,

I guess a few more words would have helped.  Stefans approach is to use the standard email submit button (so don't use the mailDoc method), this gives you the validations but means you must update the email submit button address, which he does with his "two button submit technique".

Regards

Bruce

Avatar

Former Community Member

But if you use the standard submit button you can't specify the subject, cc and all of that can you??

Avatar

Level 10

Hi,

stefan's example uses a method that seems a bit clumsy or maybe that was the only way it could be done in 2006.  Assuming your email button is called EmailSubmitButton yo can use;

EmailSubmitButton.event__click.submit.target = emailtarget;

where emailtarget is a string in this format

mailto:emailaddress?cc=emailaddress?bcc=emailaddress?subjext=text?body=text

The bold parts you can't change but you can leave out, except for the mailto and the to email address that follows it.

Regards

Bruce

Avatar

Former Community Member

Nevermind, Just realised that this is a discussion about LifeCycle and not Acrobat My bad.