1 Reply Latest reply on Oct 26, 2011 2:04 PM by George_Johnson

    Verify Checkbox before Submitting Form

    ktr927

      I have a form that has a script in the submit button to verify certain fields before submitting the form. If a field is blank an error message is generated stopping them from submitting it. I have one checkbox that also needs to be verified but can't seem to get the script to work for it. I just need to know how to word the script to make the checkbox give an error using if else. Thanks!

        • 1. Re: Verify Checkbox before Submitting Form
          George_Johnson MVP & Adobe Community Professional

          The value of a check box when it is not selected is the string "Off", but not "off", blank, false, or anything else. So the code might look like:

           

          // Get the value of the check box
          var v = getField("cb1").value;
          
          // Do something based on the value of the check box
          if (v === "Off") {
              // Check box is not selected
          } else {
              // Check box is selected
          }