6 Replies Latest reply on Oct 26, 2015 10:56 AM by Keith_S-AZ

    HELP! How do I enforce a required field

    zubobinski Level 1



      I do hope someone can help me with this!!!


      I have a pdf where I require the person before submitting to check a check box to confirm they understand a key statement. the checkbox is called Confirm.


      I have seen some javascript here http://forums.adobe.com/thread/784322 which uses on blur - but the assumption is that the user has tabbed into the field concerned... what if they skip over it?


      So... I decided to put some Javascript into the submit button...


      the submit button currently has 3 Actions on mouse up

      first it runs the following javascript

      if (Confirmed.value.length == 0)

          {app.alert("The confirmation box must be checked. Please confirm.")


      then it performs  file>save as>pdf

      then it performs submit a form and emails the pdf


      My question is - Why if you have denoted a field as required does adobe allow you to save and email a form where these fields have not been completed??? surely this is a huge bug??


      ok... but the logic I put in with the first javascript does not get triggered, can anyone explain why not? .... more importantly... can anyone help me with some code which achieves this desired effect -

      when the form is submitted, I need to check if the checkbox has been checked and if not display the above alert AND exit out of the rest of the submit actions.





        • 1. Re: HELP! How do I enforce a required field
          Test Screen Name Most Valuable Participant

          It would be a massive problem if you couldn't save an incomplete form. Often, one needs to save a form, then go away and do research (or walk away for coffee or go home), to return later with the information to complete it.


          Required fields applies to submitting, so far as I know. I have no idea why you are saving the form, and I do know why you are emailing it, but that isn't submitting a form in the classical sense.

          • 2. Re: HELP! How do I enforce a required field
            George_Johnson MVP & Adobe Community Professional

            It is not at all a huge bug. Some thoughts:


            1. Your script isn't working because it's not correct. If you want to check the state of a check box and do something based its state, the code could be something like:


            // Get the value of the check box with the field name "Confirmed"

            var v = getField("Confirmed").value;


            // The field value with either be the string "Off" (if not selected) or the export value (if selected)

            if (v !== "Off") {

                // Proceed with the submit here

                submitForm({cURL: "someone@example.com", cSubmitAs: "PDF"});

            } else {

                // Check box not selected. so alert the user

                app.alert("You must select the \'Confirmed\' check box before you can submit this form.", 3);



            2. Even if a check box is set as required, it won't prevent the submit form action or JavaScript from submitting. This is because the field always has a value. This is different for a radio button group. If none in a radio button group that is makred as required is selected, then the submit won't be allowed to take place until one is. This is just how it works, so you have to use a script instead as shown above.


            3. Can you explain why you want to save the form before it is submitted? It is automatically done when the entire PDF is submitted, so there normally wouldn't be a need to do this.


            4. Use just a single JavaScript action. If you use multimple actions, the are independent from one another, so one can't prevent a subsequent one from being triggered.

            • 3. Re: HELP! How do I enforce a required field
              zubobinski Level 1



              Thank you SO MUCH for clarifying the functionality, the answer as always

              is in keeping it simple.

              The only flaw below is the the Curl should contain mailto: but that does

              not detract from how elegant your solution is.


              I have not completed my testing yet because I have not sent my email

              just yet so not sure if the save pdf occurs automatically once the email

              has been sent.







              George Szubinski

              • 4. Re: HELP! How do I enforce a required field

                A somewhat related question from a JS newbie:


                How would this code be modified if I have several required textboxes that must be completed before the "Send Email" box displays?

                Currently, I have the alert box display first, but if I cancel the alert box, the "Send Email" box pops up right away. I want the "Send Email" box to only appear after all required textboxes are completed.


                Many thanks!

                • 5. Re: HELP! How do I enforce a required field
                  MatLac Level 3

                  The trick is to first loop throught all fields of the form and isolated the ones that have the  .required property set to true.  Then, test each of these field value property to be not equal to their defaultValue property (meaning the have been filled).  If this test passes, go ahead with your email thing.

                  • 6. Re: HELP! How do I enforce a required field
                    Keith_S-AZ Level 1

                    Thanks, MatLac.
                    As I mentioned, I'm brand new to JS. Would you be able to share some code to help me get started with this?