5 Replies Latest reply on Feb 21, 2014 10:29 AM by Test Screen Name

    Help me fix my submit button

    berocca

      Hi folks,

       

      The aim of my submit button is to enforce all of my required fields and not allow emailing until they have been completed.

       

      At the moment, when a user presses submit, they receive an alert warning them that not all required fields have been completed, however, the email client still pops up two seconds later and allows them to send.

       

      Originally, I made a submt button only using the maildoc code that I found elsewhere in this forum, but I found that this did not do anything about the required fields.

       

      So then what I did was make a button and under Mouse Up Action I have "Submit a Form" where i have specified the email address it is to go to. I also have under Mouse up Action "Run a Javascript" where I have the following code:

       


      // First, get the client CC email address
      var cCCAddr = this.getField("Text1").value;

      // Set the subject and body text for the email message
      var cSubLine = "Form for "+ getField("Field 2").valueAsString+ " "+ getField("Field 1").valueAsString+ " from "+ getField("Field 31").valueAsString;

       


      var cBody = "Form for "+ getField("Field 2").valueAsString+ " "+ getField("Field 1").valueAsString+ " from "+ getField("Field 31").valueAsString;

       

      // Send the entire PDF as a file attachment on an email
      this.mailDoc({bUI: true, cTo: cCCAddr, cSubject: cSubLine, cMsg: cBody});

       


      I know that it is not the best way to do this, however so far it is the only way I have bee able to email the form, customise the subject etc AND get it to alertthe user when they have missed required fields.

       

      Can anyone improve on my method and tell me how I can get it to not senda t all when required fields are empty?

        • 1. Re: Help me fix my submit button
          George_Johnson MVP & Adobe Community Professional

          What you can do is check each field using JavaScript and only allow the mailDoc statement to execute if all of the required fields are filled-in. This also allows you to customize feedback to the user sees when any fields are missing. The built-in one can be not so helpful.

          • 2. Re: Help me fix my submit button
            berocca Level 1

            Hi George, that's exactly what I think I need as I have seen something similar mentioned during my research but haven't found examples of such a script. Are you able to give me some more information?

             

            Also, if I do this should a remove "Submit a Form" from the Mouse up Action of the button then?

            • 3. Re: Help me fix my submit button
              berocca Level 1

              Sorry guys, I have done multiple searches for something similar to what George suggested (e.g. Javascript that only allows the mailDoc statement to execute if all of the required fields are filled-in) but I am seriously not finding anything. Time is running out unfortunately. Can any one help me?

              • 4. Re: Help me fix my submit button
                berocca Level 1

                This submit button just gets better and better! I ahev also discovered that when the form is completely emptry and one spresses submit and cancels out of the alert - when the mail client pops up - the subject line appears as intended (obviously with blanks where the field data should be) but when the form is completely filled in and submitted - there is no body or tsubejct text at all. Grrrrr.

                • 5. Re: Help me fix my submit button
                  Test Screen Name Most Valuable Participant

                  You just need to add lines to test the value of each field, and make the submitForm conditional. You can't expect Google to do your programming for you!