SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok I have created a form that has about 35 or so checkboxes. I need the user to ONLY be able to check 2 checkboxes. How can I do this easily?

I have tried to add hidden field that adds up what the user has checked but I cannot get it to work.

Any ideas?

share|improve this question

C. Marius has the right of it. Step-by-step:

Create three fields, Check1, Check2, Check3. Set each to True/False type. Default them to 0 (or FALSE, but be consistent about using 0/1 versus TRUE/FALSE). Create a fourth field, TotalChecked, set to Whole Number/Integer.

Set rules on Check1, Check2, and Check3 in the following manner:

Name: Add
When: Check1 = 1
Action: TotalChecked = TotalChecked+1

(Stop Executing When This Rule Finishes is optional but good practice to preserve performance)

Name: Subtract
When: Check1 = 0
Action: TotalChecked = TotalChecked-1

Do the same for Check2 and Check3.

Set conditional formatting on each checkbox:

If TotalChecked is greater than or equal to 2 AND
Check1 = 0
Disable this Control

Do the same for Check2 and Check3.

You should now have an illustration of the functionality you're asking for. Tailor it to suit your needs. Duplicate the checkboxes until you have 35 of them, and then change their bindings to your actual variables, and then remove Check1/Check2/Check3 from your data set. This will preserve the rules and conditional formatting, saving you an enormous amount of type.

Just make sure that if you do this (dupe checkboxes and rebind) that you use the correct 0&1/TRUE&FALSE combination that the rest of your form logic uses.

share|improve this answer

You would need to use an XPath formula to compute how many are already selected using something like

count(../preceding-sibling::*) + 1

use another field and under Default Value use the "fx" button to enter such a formula. Also make sure that on the Field or Group Properties dialog box, ensure that the Refresh value when formula is recalculated check box is selected.

Afterwards you should be able to use Manage Rules and perform your logic, e.g. disable other checkboxes if the value goes beyond the threshold by example.

share|improve this answer
I am sorry, but I am new to infopath and I do not understand really. Do I add the above formula exactly how I see it? – trikread Mar 4 '13 at 21:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.