Highlighted

Tick boxes - at least one has to be ticked

New Here ,
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
Comment review and collaborate PDF, Create PDFs, Edit and convert PDFs, PDF forms

Views

60

Likes

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

Tick boxes - at least one has to be ticked

New Here ,
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
Comment review and collaborate PDF, Create PDFs, Edit and convert PDFs, PDF forms

Views

61

Likes

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
Oct 12, 2020 0
Most Valuable Participant ,
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?

Likes

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
Reply
Loading...
Oct 13, 2020 0
New Here ,
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

Likes

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
Reply
Loading...
Oct 13, 2020 0
Contributor ,
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?

Likes

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
Reply
Loading...
Oct 13, 2020 0
New Here ,
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

Likes

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
Reply
Loading...
Oct 13, 2020 0
Engaged ,
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;

Likes

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
Reply
Loading...
Oct 13, 2020 0
try67 LATEST
Most Valuable Participant ,
Oct 13, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Oct 13, 2020 0