Skip to main content
Inspiring
March 18, 2016
Question

Need Script to Continue After Clicking OK on Alert Box

  • March 18, 2016
  • 1 reply
  • 3782 views

My form has multiple required fields. In order to ensure the form has been filled out completely, the submit button on the form has a javascript action on it to check the contents of the required fields, and if necessary, return the user to that part of the form to enter the required information.

Just before the form is mailed, I am checking for a value of "Vendor_Guidelines" in field 18. If that field's value is "Vendor_Guidelines", I would like to pop up an alert reminding the user to include the guidelines when submitting their request. They should be able to click "OK" on the alert, and continue with submitting their form.

Below is the expert of the script on the submit button. Once the alert displays, I really don't really need to set focus back to f18, I just need the user to be able to click OK and allow the script to continue so the form can be submitted.

Thanks in advance for any ideas on this.

              else if (f18.value == "Vendor_Guidelines")

  {

  app.alert ('You checked the Vendor/Buyer Guidelines checkbox on page one of this form. Attach the guidelines to this request email.');

  f18.setFocus();

  }

  else

  {

        // Email PDF.

        var m = this.getField("ad_desc");

        var mysubject = m.value + " - Request Form Submission";

        this.mailDoc(true, "requestforms@ducjvh.com", "", "", mysubject);

  }

}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
March 18, 2016

The use this code:

// original code

else if (f18.value == "Vendor_Guidelines") {

  app.alert ('You checked the Vendor/Buyer Guidelines checkbox on page one of this form. Attach the guidelines to this request email.');

}

// Email PDF.

var m = this.getField("ad_desc");

var mysubject = m.value + " - Request Form Submission";

this.mailDoc(true, "requestforms@ducjvh.com", "", "", mysubject);

kmc27Author
Inspiring
March 18, 2016

Thanks for the help.

When I make the edits, the form behaves differently:

Prior to the edit, when the "Submit" button was clicked, the form would call out any missing required fields, and not proceed with emailing the form until they were filled out;. Once all required fields were completed, the submit button would open a new email message and attach the form using the default email client.

After making the edit two things changed:

1. An alert box appears when a required field had not been completed, but it then the script proceeds to mail the form even though some required data is missing

2. The form no longer automatically opens an email using the default email client.  Instead A "Send Email" dialogue box opens asking "How would you like to send the email?. It shows two radio button choices: "Default email application (Microsoft Outlook)" or "Use Webmail"

I made the edits several times to be sure I wasn't missing anything. Do you have any suggestions for me?

try67
Community Expert
Community Expert
March 18, 2016

I was afraid of something like that... That's what happens when you only provide partial code and don't explain exactly how it's working and how it should work.

So you want the file to be submitted when the alert is shown, but not in other circumstances? If so, then move the code that's outside the curly brackets inside of them.

You'll notice I didn't change anything about how the file is being submitted, so it should work exactly the same as before, unless you changed something else.