4 Replies Latest reply on Jan 15, 2012 10:46 AM by John Frederick Chionglo

    Required radio buttons

    akshayny1

      Hey guys,

      Here is my problem: I have a form with several text fields and radio buttons. I need to make sure that:

       

      1. It wont allow the user to proceed to the next text field until the previous text field is filled in.

      2. I have a list of questions with radio buttons, so I dont want the user to go to Q2 until they complete Q1.

       

      For my first Question, I saw one of your posts had this code:

      // Validate script for text field

      (function () {

       

      // Get references to the subsequent fields to control

      var f1 = getField("other_text_field1");

      var f2 = getField("other_text_field2");

       

      // Reset the fields

      f1.value = f1.defaultValue;

      f2.value = f2.defaultValue;

       

      if (event.value) { // Show the fields if this field is not blank

      f1.display = display.visible;

      f2.display = display.visible;

      } else { // Otherwise, hide the fields

      f1.display = display.hidden;

      f2.display = display.hidden;

      }

       

      })();

       

      My form starts with Name as the first text field and ID as the second. I dont want the user to enter his ID until he enters his name. So for Name text field, under VALIDATE Tab, I selected Run custom validation script radio button and entered the following code:

      // Validate script for text field

      (function () {


      // Get references to the subsequent fields to control

      var f1 = getField("ID#");

      // Reset the fields

      f1.value = f1.defaultValue;

      if (event.value) { // Show the fields if this field is not blank

      f1.display = display.visible;

       

      } else { // Otherwise, hide the fields

      f1.display = display.hidden;

       

      }


      })();

       

       

      BUT this does not work and Im not sure why. Please help me out. I appreciate all the help. Thanks!

        • 1. Re: Required radio buttons
          John Frederick Chionglo Level 1
          Hi Akshany1,


               This is my understanding of the first problem:

               Given two text fields. The first field must be filled in before the second
               field can be filled in. When the first field is empty, the second field takes
               on properties which prevents a user from entering or modifying text in the
               second field. For this example, the visibility of the text field will be used
               to keep the user from entering or modifying text; it is hidden when the
               first field is empty, and it is visible when the first field is not empty.

               This means that the visibility of the second field depends on the content
               of the first field. It is sufficient to have the validation script in the first field.

               Here is a version with related diagrams and an example:

               http://www.aespen.ca/AEnswers/Akshany1-Dec012011-reply.pdf

               I hope this helps. Regards, John.
          • 2. Re: Required radio buttons
            gkaiseril MVP & Adobe Community Professional

            Radio buttons and check boxes have a string value of "Off" when none of the radio buttons or check boxes within an exclusionary group (fields with the same name but different export values).

             

            You will have to check if the value of the radio buttons or check boxes have a value of not equal to "Off" to unlock the next question.

            • 3. Re: Required radio buttons
              akshayny1 Level 1

              @jfchionglo2 - this is exactly what i want. I understand this logic too but I dont know the technicality in how to make it funtion that way. I need help putting this logic into funtion/programming. Please help!

              • 4. Re: Required radio buttons
                John Frederick Chionglo Level 1

                For this example problem (your first problem), I added the following (custom) validation script to the field called Text1:

                 

                /*** Start of (custom) validation script ***/

                 

                      (function() {

                 

                        var tf1 = this.getField("Text1");

                        var tf2 = this.getField("Text2");

                 

                        if (event.value) {

                          tf2.display = display.visible;

                        } else

                          tf2.display = display.hidden;

                 

                      })();

                 

                /*** End of (custom) validation script ***/

                 

                I forgot to mention that I actually added this validation script to the field called Text1 in the PDF document I referenced earlier.

                 

                Are questions one and two independent of each other?

                 

                Regards,

                 

                John