• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Tick boxes - at least one has to be ticked

New Here ,
Oct 12, 2020 Oct 12, 2020

Copy link to clipboard

Copied

Hi Community, 

 

I have the following scenario in a PDF form. 

 

Under a question, I have three tick boxes, at least one needs to be ticked, but also either two or all three can also be ticked. 

Can someone please advise the appropriate Javascript to use?

 

Thanks Claire 

 

 

 

TOPICS
Create PDFs , Edit and convert PDFs , PDF forms

Views

522

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Just give each field a unique name and they'll work independently of each other.

When you say that "at least one fields needs to be checked", what do you mean by that, exactly? What should happen if no fields are checked?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Thanks for responding. So they need to select at least one of the below to able to "submit" the application. No fields are allowed to be left unchecked. Screen Shot 2020-10-13 at 9.17.56 pm.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Do you want to make checkboxes required if you use submit or you just want that user need to check one of the boxes?

If it's latter then you need to describe us a scenario how you are using boxes?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Thanks for responding. So yes, to allow the user to submit the form they need to check at least one of the checkboxes as a response to the question. But they can also check multiple boxes. 

 

Screen Shot 2020-10-13 at 9.17.56 pm.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

You can make checkboxes required but it won't do you any good since submit check for empty value
and checkboxes are never empty.What you need is make hidden text field and use script in it, when no checkboxes are tick
field will be required and if any checkbox is tick field is not required.
You can try using this script as custom calculation script of hidden text field, and change field names if needed.
var c1 = this.getField("Check Box2").value;
var c2 = this.getField("Check Box3").value;
var c3 = this.getField("Check Box4").value;
if(c1 != "Off" || c2 != "Off" || c3 != "Off"){
event.value = "Required";}
else event.value = "";
if(event.value == ""){
event.target.required = true;}
else event.target.required = false;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

LATEST

This will work, but the problem is it will be unclear to the user what fields they are missing when trying to submit the form.

It's better to use a script for the Submit button in which you control that either one of those check-boxes is ticked (as well as all other required fields), and if so, submit the file. If they're not you display an error message to the user, explaining what the issue is.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines