Jump to content
  • 0
Vitalikssssss

Make at least one checkbox required

Question

1 answer to this question

Recommended Posts

  • 0

Hi @Vitalikssssss,

You may use the following code to prevent submittion if non of the checkboxes were not checked:
 

<script>

document.addEventListener("BeforeFormSubmit", myFunction);

function myFunction() {
    let FirstField = document.getElementById("InsertRecordnnn").checked;
    let SecondField = document.getElementById("InsertRecordname").checked;
    let ThirdField = document.getElementById("InsertRecordTF").checked;
    let FourthField = document.getElementById("InsertRecordnumber").checked;

    if (!FirstField && !SecondField && !ThirdField && !FourthField) {

        event.preventDefault();
        //for hiding the button container:
        //document.getElementsByClassName("cbSubmitButtonContainer")[0].style.display="none";
    }
};

</script>

The code should be added into the datapages' footer. Also you should rename the fields in the code to the ones you have on your form. Please see the screenshot for better understanding:
image.png.daa195daf2b96e416afddc3b564aaa43.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...