9 Replies Latest reply on Jul 12, 2014 1:42 PM by MatLac

    very new trying to make conditional required text

    windriver14

      Very new at this. I am trying to create a conditional required text and hide certain boxes after filled out but still be able to access them when they are sent back to me.

       

      can anyone help?

        • 1. Re: very new trying to make conditional required text
          MatLac Level 1

          put this script in the calculate event of the field that needs to be required:

           

          if (insert condition here){

          event.target.required = true;  //for accessing the required property

          event.target.display = display.hidden;  //for hidding certain fields

          }

          else{

          event.target.required = false;

          event.target.display = display.visible;

          }

           

          that takes care of the required fields and/or hidden fields

           

          as for the other part, I think the easiest way would be to add a password protected button that would make every field visible.  If you like this idea, let me know.

          • 2. Re: very new trying to make conditional required text
            windriver14 Level 1

            If I copy that and paste it into the "custom calculation script" do I enter the box name(General tab Name) in the (insert condition here) of the field I want to require if this one is filled in?

             

            Also The for will have information on it such as SSN, Credit card number or bank account number. I would like those to not be visible but to be able to access them when they come back to me.  would a password be the best way to do that? I was planning on encrypting the form when I send it out.

            • 3. Re: very new trying to make conditional required text
              MatLac Level 1

              I'm guessing you want SSN, CREDIT and BANK to be required when NAME is filled in or something like that.  Then, the condition would be (this.getField("NAME").value != "") meaning that the value of the field IS NOT empty.

               

              As for the other part, a password button is probably not what you are looking for.  I don't understand what you mean by not being visible but being able to access them.  If the user needs to fill it, it needs to be visible.  And if they're already in the form but just invisible to the user, doesn't it pose a security risk since the form will be handled by other people.  Know that adobe security is not garanteed if pdfs are viewed with a third party software.

              • 4. Re: very new trying to make conditional required text
                windriver14 Level 1

                Thanks for the help, I have used PDFs in the past where when you fill in your SSN and click off the text box it will turn it to xxx-xx-4124 for example purposes. It makes the person filling out the form feel more protected. at the same time when filling out the form and sending it back someone has to be able to see that number for the files.

                • 5. Re: very new trying to make conditional required text
                  MatLac Level 1

                  In the format tab of the SSN number, choose "Special format" and then SSN format.  Acrobat has some built-in formats but it is possible to create any format you want by combining Keystroke, validate and format events

                  • 6. Re: very new trying to make conditional required text
                    MatLac Level 1

                    Place this in the custom format of the format tab for turning numbers to ****

                     

                    if(event.value.length == 9){

                    event.value = "***-**-"+event.target.valueAsString.substr(5);

                    }

                    else {

                    event.value = "";

                    }

                     

                    you can also add an alert

                     

                    app.alert("Invalid SSN!  Please try again");

                    • 7. Re: very new trying to make conditional required text
                      windriver14 Level 1

                      Great thanks! Will I also be able to reverse it to access the information when they send it back?

                      • 8. Re: very new trying to make conditional required text
                        windriver14 Level 1

                        Can I use the same formula for Credit Cards? Below is what my form looks like. I would like to be able to send it out have everyone feel safe that their information is secure at the same time be able to get it back and input into my software that keeps track of their memberships and billing information.

                        • 9. Re: very new trying to make conditional required text
                          MatLac Level 1

                          Add this to the custom keystroke event (also found under the format tab).  It will prevent the user from inputting anything else than numbers in the fields (SSN and CREDIT)

                           

                          var re = /\d|^$/;   //Regular expression

                          if (!event.willCommit){  //if value is not yet committed

                            if(re.test(event.change) == false){  //if the keystorke enterdered doesn't match the expression above

                            event.rc = false;  //erase last keystroke

                            }

                          }

                           

                          You can adapt both scripts to reflect the needs for a credit card field.  The only difference with Credit cards is they don't always have the same syntax than SSN.  Plus, the have dedicated numbers like I think all VISA start with 45 or something.  Knowing this, you should create regular expressions to test if Card numbers are valid and/or from the right brand of card.

                           

                          instead of using .substr(5);   //retain digits at position 5 until the end

                          I would change it to .substr(event.value.length-4);  //retain the last four digits

                          This way, you will always have the last four numbers no matter how long the number is


                          There is a lot of things that can be done with such a form to further enhance it.