2 Replies Latest reply on Jan 31, 2010 7:54 PM by ndjustin20

    If radio button is selected then X field is required code

    ndjustin20 Level 1

      I am trying to figure out how to code a field to become required when a user selects a radio button or something from a drop down list.  what I am trying to do really is figure out how I can setup a variable inside the required syntax and figure out where the required syntax actually is inside say a radio button as currently I can't find it.  I could setup the function to be called when the radio button is selected and from there the function can change it to required or not required depending on selection.  I hope this makes sense and thank you in advance for the help.

       

       

      Justin

        • 1. Re: If radio button is selected then X field is required code
          Steve L Walker Level 5

          Justin,

           

          Take a look at the attached. It contains script to check both a radio button exclusion group and a drop-down to request form fill on a text field. Each script is attached to the exit event of the relevant text field.

           

          Steve

          1 person found this helpful
          • 2. Re: If radio button is selected then X field is required code
            ndjustin20 Level 1

            Hello Steve,

             

            Thank you very much for the reply.  I am uploading the form I am working with and a screen shot of what I am trying to do.  I've figured out that "<validate nullTest="error"/>" is added to an object when i change it to "user required".  I really like how adobe handles this error and stops all other processes and want to use this method.  My questions is this.  How to store "<validate nullTest="error"/>" well I mean i can store it using something like:

             

            var required = <validate nullTest="error"/> or something like that depending on how adobe handles syntax which I'm still a little shaky on.

             

            BUT how can I place this variable inside of the syntax of the object to make sure it is read before moving on to the next line of code?   I was thinking of a function to check for diffferent cases of an object as there are different objects i want to check to see if they equal "1" or !=NULL or something along those lines.

             

            function checkValue()

            {

             

              if (object1.rawValue == "1")

            {

                 required = <validate nullTest="error"/>;

                 break;

            }//end if

            if (object2.rawValue == "Y")

            {

                 required = <validate nullTest="error"/>;

                 break;

            }//end if

            }//end checkValue

             

             

            I really really appreciate your help with your last response and I could use the first method though what happens is that even though the error comes up I'm still able to email the form and I want the email process to stop altogether so it forces the required field to be populated with data.

             

             

            I need something like:

             

            <script contentType="application/x-javascript">

            if (RadioLocation.rawValue == "1")

            {

            document.write(<

            validate nullTest="error"/>);

             

            }

            </

            script>

             

            But I can't figure out how it is supposed to work inside of the code exactly.

             

            Justin