7 Replies Latest reply on Oct 17, 2012 2:58 PM by bjmccoy

    Help with validating radio buttons

    bjmccoy Level 1

      I would like to set my radio button so they can only click it after they have entered text into the 2 previous text fields.  Can someone help me out with a script how to do that?

       

      Thanks

        • 1. Re: Help with validating radio buttons
          George_Johnson MVP & Adobe Community Professional

          What should happen if either of the text fields is later set to blank after the radio button is selected?

          • 2. Re: Help with validating radio buttons
            bjmccoy Level 1

            Maybe a pop up message that tells them they need to enter data in those field first.

             

            I have it set so when they hit one of the radio buttons it sends an e-mail but the e-mail takes data from those other 2 text fields so if they do not enter them first the e-mail will not be able to get that data.

             

            Thanks for the help

            • 3. Re: Help with validating radio buttons
              bjmccoy Level 1

              Or is there a way to just grey them out until the other 2 text fields have been filled in?

              • 4. Re: Help with validating radio buttons
                Mandeep5062 Employee Moderator

                Please try the following Script :

                 

                // Function to enable form fields function

                EnableFormField (cFieldName) {

                // First acquire the field to be enabled

                var oFld = this.getField(cFieldName)

                // Next acquire the hidden field with the normal colors

                var oNmlFld = this.getField("NormalColorsFld");

                if(oFld) {

                // Make field interactive

                oFld.readonly = false;

                // Restore Normal Colors

                oFld.fillColor = oNmlFld.fillColor; oFld.borderColor = oNmlFld.borderColor; oFld.textColor = oNmlFld.textColor;

                }

                }

                // Function to disable form fields function

                DisableFormField(cFieldName) {

                // First acquire the field to be disabled

                var oFld = this.getField(cFieldName)

                if(oFld) {

                // Make field Read-Only

                oFld.readonly = true;

                // Set Grayed out colors

                oFld.fillColor = ["G", 0.75]; oFld.borderColor = ["G", 2/3]; oFld.textColor = ["G", 0.5];

                }

                }

                • 5. Re: Help with validating radio buttons
                  bjmccoy Level 1

                  I did find that script but I haven't been able to get it to work.

                   

                  Do I put all of that in the radio button or the text field?

                   

                  I also read somewhere that it had to be a document script.

                   

                  Please advise me thanks!

                  • 6. Re: Help with validating radio buttons
                    bjmccoy Level 1

                    Ok I have made some progress.  I added that script to my document.  But this is the script that I have now on my text box (qty) to enable/disable a check box (valid).

                     

                    if ((event.value!="")&&(event.value>=15))
                    DisableFormFieldToGray("valid")

                    if (event.value<15) EnableFormFieldFromGray("valid")

                     

                    I want it to disable the field if the field is empty or has a value greater or equal to 15.  I works for if its greater than 15 but not if its empty.

                    It also do not work when the field is less than 15, it just brings up an error:

                     

                    oNmlFld is null

                    11:AcroForm:qty:Validate

                    TypeError: oNmlFld is null

                    11:AcroForm:qty:Validate

                    • 7. Re: Help with validating radio buttons
                      bjmccoy Level 1

                      I figured out that error, the only thing I have left to figure out is to disable the check box then the text field is empty.