Announcement

Collapse
No announcement yet.

Required Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Required Fields

    On an interactive form, is there a way to require that certain fields be filled in? We have inspection forms that must be filled out properly and the desire is to not allow saving or printing the form unless certain fields have been filled in/checked/whatever.

  • #2
    Post_Foxit Your requirement can be accomplished by Javascript. Can you please give me your email address and I can send demo file with JS to you for reference? Also, you can send email to us via [email protected]
    Thanks.

    Comment


    • #3
      Yes you can use [email protected], and thank you.

      Comment


      • #4
        Post_Foxit Hi, the email with demo file was sent to you. Please check and let me know your idea, thanks

        Comment


        • #5
          Hi there, can I please get the information on how to do this as well? My email is [email protected]. Thank you!

          Comment


          • #6
            A user may have many good reasons for wanting to save or print a form before having finished filling it out (announced power cut, appointment, interruption, emergency, etc.).
            Luckily for him you can't prevent him from saving or printing.

            It is much more user-friendly to just display an alert when the user is saving or printing.

            Comment


            • #7
              Originally posted by Aleung
              Hi there, can I please get the information on how to do this as well? My email is [email protected]. Thank you!
              Actually, it is easy to do it. Please follow the directions below:
              1. Open the document in Foxit PDF Editor.
              2. Click on the Form Fields panel on the left nav.
              3. Right click on the form to be required.
              4. Under General Tab, check the > Required < checkbox.

              Comment


              • #8
                Here is what I do:
                • Create a Document JavaScript Function called Required with the following code.
                Code:
                function Required() {
                  var c = 0;
                  for (var i = 0; i < this.numFields; i++) {
                    var fieldName = this.getNthFieldName(i);
                    var f = this.getField(fieldName);
                    if (f.type != "button") {
                      if (f.required == true && (f.value == "" || f.text == "")) {
                        c++;
                      }
                    }
                  }
                  if (c > 0) {
                    app.alert("At least one required field is empty...",1);
                    c = 0;
                  }
                  return;
                }
                • Then simply called the function with
                  Code:
                  Required();
                  in a field Action from the field properties: Actions > Select a Trigger > Select Action "Run a JavaScript"
                I will note a few things: 1) this only checks if the Required fields are not blank and if one is then a simple warning alert is issued; there is nothing stopping the user from continuing to sign the PDF, for example... and 2) this works for Foxit PDF Editor for Mac and Foxit PDF Editor Pro for Windows (Parallels VM) but I cannot get these to work on Adobe Reader on either OS.

                EDIT: do not use JS6 code, such as "let" or "const"; use "var." I have made this replacement in my code above.
                Last edited by cwb162; 03-01-2022, 03:44 PM.

                Comment


                • #9
                  cwb162

                  Thanks for the details. The mentioned two discoveries have been submitted to Foxit internal bug tracking system for our JS engineer's further investigation and we'll keep you posted with the update. You may also use the Report ID#QCPHANTOM-29435 to track the processing status any time. Thank you.

                  Comment


                  • #10
                    Originally posted by cherry
                    cwb162

                    Thanks for the details. The mentioned two discoveries have been submitted to Foxit internal bug tracking system for our JS engineer's further investigation and we'll keep you posted with the update. You may also use the Report ID#QCPHANTOM-29435 to track the processing status any time. Thank you.
                    Thanks, Cherry. I made an edit to my code. The JS6 code, like "let," does not compute for Adobe JS so you have to use the traditional "var." This topic was resolved in my post here: https://forums.foxitsoftware.com/for...editor-for-mac.
                    Last edited by cwb162; 03-01-2022, 03:49 PM.

                    Comment

                    Working...
                    X
                    😀
                    🥰
                    🤢
                    😎
                    😡
                    👍
                    👎