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

User cannot submit form IF Grand total is less than $50

Ginthom
Registered: Sep 13 2010
Posts: 4
Answered

Hi,

I've created a form that lets you order items in a list with a grand total at the bottom.

All the user does is input quantities then the price per line and the grand total at the bottom are automatically calculated. The user then presses submit and I receive an email with their order.

Simple.

What I'd like to do is not let the person be able to submit the form unless their order is a minimum of $50.

I assume I need to put a conditional statement in the action on the submit button??? But unfortunately I've never coded in javascript and have no idea what the code would be. Would it be some sort of if statement stating [if Grand Total is < 50 spit out this message "blah blah blah", else submit form]

Could anybody enlighten me please?

Thank You.

My Product Information:
Acrobat Pro 9.3.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You will need to use something like this:
var grandTotal = this.getField("Grand Total").value;if (grandTotal==null || grandTotal=="" || grandTotal<50) {app.alert("You can't submit the form because the grand total is smaller than $50.");} else {this.submitForm();}

You will need to adjust the name of the Grand Total field, as well as the parameters for the submitForm function. Have a look at the reference files for more info.

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

Ginthom
Registered: Sep 13 2010
Posts: 4
Thanks Try.

I got the message to pop up for orders under 50, but now I'm totaly confused as to how to get the submit a form function to work.

Again I have no idea about javascript so I'm not sure what reference files to look at/for. Do you mean press F1 in acrobat? If so, what do I look for? I searched for the submit form function but it just tells you to choose 'submit a form' in the action tabs menu.

I only know how to use the basic form functions in the action tab. I had to replace the 'submit a form' action with the 'run a javascript' action and put in your code, changed the grandtotal part as you suggested and got it to work, but now I don't know where to put the submit details in.

Thanks
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Have a look here:
http://www.adobe.com/devnet/acrobat/javascript.php

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

Ginthom
Registered: Sep 13 2010
Posts: 4
Thanks again Try.

I think I found it at http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.537.php

I was meant to put quote "" marks around ("mailto:emailadd") inside the submitForm brackets.


Edit: Above link fixed.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
If you want to mail the file, instead of submitting it to a server, you can also use the mailDoc function.
And yes, literal strings need to be placed between single or double quotes.

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

Ginthom
Registered: Sep 13 2010
Posts: 4
try67 wrote:
If you want to mail the file, instead of submitting it to a server, you can also use the mailDoc function.
Yep the form gets submitted as an fdf file

It works perfectly now.

Thanks again for your help.