10 Replies Latest reply on Oct 30, 2015 6:25 AM by Abureesh

    How to JavaScript?

    Abureesh

      Hi Everybody,

      I would highly appreciate it if anyone could help on this.

      How to make more than one field required in a form by checking one CheckBox?

      Thanks in advance.

        • 1. Re: How to JavaScript?
          try67 MVP & Adobe Community Professional

          Do you know how to do it for one field? If so, then just duplicate that

          command for the other fields as well...

          • 2. Re: How to JavaScript?
            Abureesh Level 1

            Thanks a lot for your reply.

             

            I used the following script and it works for one field only.

            *********

            function makeFieldRequired() {

                var fields = ["Check Box102"];

                var yes = false;

                for (var i in fields) {

                    if (this.getField(fields[i]).value=="Yes") {

                        yes = true;

                        break;

                    }          

                }

              

                this.getField("Text103").required = yes;

             

            makeFieldRequired();

            ************

            I tried to do the following with the multi filed, but it doesn't work:

            *********

            function makeFieldRequired() {

                var fields = ["CCheck BoxCheck Box95"];

                var yes = false;

                for (var i in fields) {

                    if (this.getField(fields[i]).value=="Yes") {

                        yes = true;

                        break;

                    }          

                }

              

                this.getField("Text96", "Text98", "Text99", "J1", "City1", "Country1").required = yes;

            }

            makeFieldRequired();

            **************

            I tried to repeat the script for each filed in the same "Action," but it doesn't work, too.

            All these attempts are in vain.

            • 3. Re: How to JavaScript?
              Bernd Alheit Adobe Community Professional & MVP

              Use something like this:

                  this.getField("Text96").required = yes;

                  this.getField("Text98").required = yes;

                  ...


              • 4. Re: How to JavaScript?
                Abureesh Level 1

                Thank a bunch Brend,

                 

                I used your recommendation as follows, but again doesn't works. I am not sure what is wrong that is I am doing!

                 

                function makeFieldRequired() {

                    var fields = ["Check Box95"];

                    var yes = false;

                    for (var i in fields) {

                        if (this.getField(fields[i]).value=="Yes") {

                            yes = true;

                            break;

                        }          

                    }

                  

                    this.getFields("Text96").required = yes;

                    this.getFields("Text98").required = yes;

                    this.getFields("Text99").required = yes;

                    this.getFields("J1").required = yes; 

                }

                makeFieldRequired();

                • 5. Re: How to JavaScript?
                  Bernd Alheit Adobe Community Professional & MVP

                  What is not working? What is the content of the field "Check Box95" ?

                  • 6. Re: How to JavaScript?
                    try67 MVP & Adobe Community Professional

                    You have errors in your code. Check the JS console and you should see some error messages there that will help you solve the problem.

                    • 7. Re: How to JavaScript?
                      Abureesh Level 1

                      Thanks a lot Bernd.

                      Your help is highly appreciated.

                      I discovered the error. The S in the end of getFild.

                       

                      this.getFields("Text96").required = yes;

                      • 8. Re: How to JavaScript?
                        Abureesh Level 1

                        Thanks a lot try67

                        Your help is highly appreciated.

                        I discovered the error. The S in the end of getFild.

                         

                        this.getFields("Text96").required = yes;

                        • 9. Re: How to JavaScript?
                          try67 MVP & Adobe Community Professional

                          Correct. Does it work now, then?

                          • 10. Re: How to JavaScript?
                            Abureesh Level 1

                            Yes, it works perfectly.

                            Thanks.