11 Replies Latest reply on Dec 18, 2015 8:40 AM by Keith_S-AZ

    Prevent "Send Email" dialog until required fields are completed

    Keith_S-AZ

      I'm new to JS, & am struggling with one last piece of code.

      I have a form with several required fields. I am sending the form as an email attachment and need the required fields completed before the form can be emailed.

      Currently, I have an alert box display if any of the required fields are blank, but if I cancel the alert box, the "Send Email" dialog pops up right away and I can email the form even if the required fields are blank. I want the "Send Email" box to only appear after all required textboxes are completed.

      The problem seems to be with the if/else line (IF any req. fields are blank, send alert. ELSE open the "Send email" box). What’s the best way to write this? Ideally, I'd like the alert to list the specific fields that are blank. Here's what I have at the moment - but obviously have something wrong):

       

      if (requiredFields.length > 0) {
      app.alert(error);

      } else


      var subject = this.getField("JobNumber").value + " --  Request Form";
      this.mailDoc({
      cTo: "me@mycompany.com",

      })

       

       

      (Using Acrobat XI - Thanks in advance!)