2 Replies Latest reply on Jul 17, 2009 12:15 PM by SueLW

    Simple Thing - Totally Lost

    dannysporea

      Hello all,

       

      I thought myself pretty proficient in JavaScript (for HTML pages) and I am trying to do a very simple thing in Acrobat and feel totally lost...

      I have a simple form with 2 fields: two mutually exclusive Yes/No checkboxes (same name), one text field and one submit button.

      The checkboxes are required and I set the "Required" checkbox in the Properties page. The "Submit" buttons is set to submit the form to an email address (whole PDF) when clicked. If I don't check any of the checkboxes, the submission doesn't work and an error is displayed, which is the desired functionality. However, I want the following very simple validation: if the checkbox is "Yes", the form should NOT be submitted unless some text is entered into the text field (some conditional validation is required).

       

      Where should I put the script that checks this condition on the submit event ?

      I tried to put the following script into the text fields's "Run Custom Validation Script" property, yet the form is submitted and no error message is displayed if "Yes" selected and the text field is left empty:

       

      event.rc = ((this.getField("myTextField").value != "") || (this.getField("myCheckBox").value == "No"));

       

      Please help with a small crash course on how to do this kind of conditional validations, or a link with an example.

      I can handle JavaScript, but am totally lost when it comes to Acrobat forms and events and where the JavaScript needs to go...

       

      Thank you !

        • 1. Re: Simple Thing - Totally Lost
          SueLW

          Did you try putting it on the Submit button?

           

          You could possibly adapt this script that I use on my EMAIL buttons:

          var cResponse = app.alert ("Did you remember to sign the form?\n\nChoose YES to proceed or choose NO to go back and sign the form.",2,2);

          if (cResponse ==4)   {
              var nResponse = app.alert("Don't forget to attach all pertinent receipts to the email.",3,0);
              if (nResponse ==1); {
              this.mailDoc(true);
          }}

           

          Since you say you know Javascript, you can probably adapt it better than I could.

          • 2. Re: Simple Thing - Totally Lost
            dannysporea Level 1

            Thank you for your answer ! Yes, I figured it out finally that it should be on the button, and not on the field itself.

            Originally I thought that the validation script on the field will be executed on submit, which doesn't happen. It seems to be executed when you finish editing that field, which is not what I wanted.