Skip to main content
Participant
October 20, 2024
Answered

Multiple check box to code

  • October 20, 2024
  • 2 replies
  • 495 views

Hi, I am very new to javascript and just use it for basic forms for my business. This is the code that I have. It basically check if a checkbox is checked and then make a text box required. The problem that I have is it needs to check if either or all of 3 check boxes are checked. 

 

if(this.getField("CB1").value=="No") { this.getField("Note_Hand").required=true; } else { this.getField("Note_Hand").required=false; }

 

I Tried something like this but with no success

 

if(this.getField("CB1" ,"CB2", "CB3").value=="No") { this.getField("Note_Hand").required=true; } else { this.getField("Note_Hand").required=false; }

even tried

if(this.getField("CB1" or "CB2" or "CB3").value=="No") { this.getField("Note_Hand").required=true; } else { this.getField("Note_Hand").required=false; }

 

Please can someone help

    This topic has been closed for replies.
    Correct answer Nesa Nurani

    or in JavaScript is ||, so try like this:

    if(this.getField("CB1").value=="No" || this.getField("CB2").value=="No" || this.getField("CB3").value=="No")

     

    If all 3 need to be checked, replace || with &&

    2 replies

    Nesa Nurani
    Community Expert
    Nesa NuraniCommunity ExpertCorrect answer
    Community Expert
    October 20, 2024

    or in JavaScript is ||, so try like this:

    if(this.getField("CB1").value=="No" || this.getField("CB2").value=="No" || this.getField("CB3").value=="No")

     

    If all 3 need to be checked, replace || with &&

    kglad
    Community Expert
    Community Expert
    October 20, 2024

    assuming this is an acrobat pro question...

     

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



    <"moved from using the community">