0 Replies Latest reply on Apr 4, 2008 11:45 AM by (Suzy_Q)

    Check Required Fields Before Emailing Document - Problem with Email Function

      I am using Acrobat 8 Pro. I am trying to create an e-mail button on a form, but want to check that required fields have been completed before sending the email. I have the following code to verify that required fields have been completed, and if not complete ... prompts the user to the field needing attention. My problem is adding the attach to email function - I can't seem to get it right (I've eliminated my attach to email code from the following as it was creating 8 emails.) Can anyone assist? Thank you in advance. :)

      // These are the required fields on the form.
      // Populate array with their names.
      var requiredFields = new Array(8);
      requiredFields[0] = "Traveler";
      requiredFields[1] = "Email";
      requiredFields[2] = "City";
      requiredFields[3] = "State";
      requiredFields[4] = "TravelBegin";
      requiredFields[5] = "DeptName";
      requiredFields[6] = "Account";
      requiredFields[7] = "Balance";

      var alertMsg = new Array(8);
      alertMsg[0] = "Please enter the name of the traveler.";
      alertMsg[1] = "Please enter a valid city e-mail address so that if the request is denied ... it will be returned to the proper person.";
      alertMsg[2] = "Please enter the name of the city you are traveling to.";
      alertMsg[3] = "Please enter the name of the state you are traveling to.";
      alertMsg[4] = "Please enter the first date of travel.";
      alertMsg[5] = "Please enter the department name for the traveler.";
      alertMsg[6] = "Please enter an account number to charge expenses to - one account only.";
      alertMsg[7] = "Please enter the current balance remaining in the account you intend to charge the travel to.";

      var emptyTest = /^\s*$/;

      var fieldCount = requiredFields.length
      var fld = 0;

      for (var i=0; i < fieldCount; i++)
      fld = this.getField(requiredFields[i]);
      if( emptyTest.test(fld.value) ) // if required field is empty