6 Replies Latest reply on May 14, 2013 10:10 AM by c_n_crawford

    Need js for alert @ Submit button when Radio1 = YES but Radio2 left blank in error

    c_n_crawford

      My form (Acrobat X) has a submit button with javascript that checks to ensure all required questions are answered. Works great for all questions except for the situation where if  radio 1 = YES, then radio button 2 must be completed.  I can make it work for each question separately but cannot figure out how to make it check radio1 (YES) AND radio2 (left blank).

       

      Any help you can provide will be greatly appreciated!!

       

      Here's a sample of what I think is the pertinent code (I am a total newbie, BTW):

       

      var errSec2 = ""

      var errMsg = ""

      var tmpVar = ""

       

       

      // Check if r_radio1 field if populated

      tmpVar = this.getField("r_radio1");

      if (tmpVar.value !==  "YES" && tmpVar.value !==  "NO") errSec2 += " - You failed to answer this question - If you answer NO, you must answer the following question\r\n";

       

        //Check if anything was left out of Section II if so insert

        //title and add to errMsg                                  

      if (errSec2 != "") errMsg = errMsg + "\r\nSECTION II is incomplete. \r\n" + errSec2;

       

        //Check to see if there has been any fields not populated  

        //Pop alert to correct errors found or print to default  

      if (errMsg != "") {

          app.alert({

          cMsg: errMsg,

          cTitle: "Validation Error! Entry required for"});

      }

      else {

          this.print(true);

      }