1 Reply Latest reply on Jul 10, 2014 9:14 AM by Magus069

    How to validate checkboxes?

    On Ming 268

      Hi All, may I ask your advice how to implement following items?

       

      Software: Adobe LiveCycle Designer ES4

      Usage: Create PDF form and allow user to save inputted records (with LiveCycle Server or Acrobat 9 Pro)

       

      I tried to add three checkboxes for the test, and I would make sure:

      1) Users should selected at least one checkbox before save.

      2) If user selected checkbox 1, the form should not allow user to select checkbox 2 and 3.

      3) User is allowed to select both checkbox 2 & 3, but not vice versa.

       

      How can I add the validation rule for above checkboxes (if JavaScript is required, how to add it?),

      Besides, if some coding is required, could you please provide some samples to me for follow-up?

       

      e.g.

      if (CheckBox1.rawValue == "0" && CheckBox2.rawValue == "0" && CheckBox3.rawValue == "0")

      {

      alert('Please select at least one record')

      }

      else if

      {

        //I don't know >///<

      }

       

      Thank you very much (^人^)

       

       

       

       

       

       

       

       

       

       


        • 1. Re: How to validate checkboxes?
          Magus069 Level 4

          Hi, first if you dont want the user to choose more than one option if the checkbox 1 is chosen, you will have to put scripts in all 3 checkboxes to verify if your conditions are followed as you want.

           

          CheckBox1:change::event

          if (CheckBox2.rawValue == 1 || CheckBox3.rawValue == 1){

               CheckBox2.rawValue = 0;

               CheckBox3.rawValue = 0;

          }

           

          CheckBox2:change::event  && CheckBox3:change::event

          if (CheckBox1.rawValue == 1 && this.rawValue == 1){

               CheckBox1.rawValue = 0;

          }

          if (CheckBox1.rawValue == "0" && CheckBox2.rawValue == "0" && CheckBox3.rawValue == "0")

          {

          alert('Please select at least one record')

          }

          else

          {

               //Because of your verification in the change event of all 3 checkboxes, here you do what is needed according to the choices made, since when you change a value of a checkbox, the values stays valid

               //You have 3 different options here

               if (CheckBox1.rawValue == 1){

                    //codehere

               } else {

                   //here you do any validation on how your 2 other checkboxes are suppose to affect your form.

               }

          }