none
Disable the Submit button until one of the checkboxes is checked via Rules only

    Question

  • I am building Infopath 2010 form without any code behind. I need to use just Rules for this projects. I have 3 checkboxes in top half of the form and other 7 checkboxes on bottom half of this form. I want to disable Submit button until atleast 1 checkboxes from the first 3 and second 5 checkboxes are checked. I have tried the following but does not work.

    Added following rules on the Submit button: (CB stands for checkbox)

    1. not((my:CB1 | my:CB2| my:CB3| my:CB4| my:CB5| my:CB6| my:CB7)[. = "true"])
    2. CB1 is equal False and CB2 is equal False and CB3 is equal False

    What am I missing here?


    Thanks Snehal H.Rana SharePoint Consultant

    Thursday, July 05, 2012 3:12 PM

Answers

  • Matthew,

    I tried a different approach as below and it worked like a charm:

    1. Created two text field called cbtotal1 and cbtotal2
    2. Don't need to have these field on the design area
    3. Data type of these text fields is Whole Integer
    4. Change each checkboxes properties to "0" for Clear and "1" for Checked
      cbtotal 1 = cb1+cb2+cb3 (check boxes from top half)
      cbtotal 2 = cb4+cb5+cb6+cb7+cb8+cb9+cb10 (check boxes from bottom half)
    5. On Submit button I added following formatting rules:
      cbtotal1 is equal to "0" or cbtotal2 is equal to "0"
      Disable this control

    That did the trick. Hope someone might benefit from this solution. Thanks for your solution though it is also a good approach.


    Thanks Snehal H.Rana SharePoint Consultant

    • Marked as answer by Snehal Rana Thursday, July 05, 2012 6:16 PM
    Thursday, July 05, 2012 6:16 PM

All replies

  • Snehal,

    This is tricky using rules as you can't exaclty loop through a set of controls.

    I would recommend the following approach:

    1.  Group your checkboxes in the data source according to your requirements (1 group has 3 fields, the other has the second 5)
      -- define checkbox fields as integer data types instead of boolean
    2.  Using XPath, you can get the Max value of a group, if it is "1" then one of the checkboxes is selected, if is "0", then none are selected
    3.  Using the functionality in step #3, you can run an action rule to disable to submit button
      -- alternatively, you could run a validation rule to prevent submission instead of disabling the button

    Thursday, July 05, 2012 3:52 PM
  • Matthew,

    I tried a different approach as below and it worked like a charm:

    1. Created two text field called cbtotal1 and cbtotal2
    2. Don't need to have these field on the design area
    3. Data type of these text fields is Whole Integer
    4. Change each checkboxes properties to "0" for Clear and "1" for Checked
      cbtotal 1 = cb1+cb2+cb3 (check boxes from top half)
      cbtotal 2 = cb4+cb5+cb6+cb7+cb8+cb9+cb10 (check boxes from bottom half)
    5. On Submit button I added following formatting rules:
      cbtotal1 is equal to "0" or cbtotal2 is equal to "0"
      Disable this control

    That did the trick. Hope someone might benefit from this solution. Thanks for your solution though it is also a good approach.


    Thanks Snehal H.Rana SharePoint Consultant

    • Marked as answer by Snehal Rana Thursday, July 05, 2012 6:16 PM
    Thursday, July 05, 2012 6:16 PM
  • Nicely done!  Sounds even a bit simpler than what I proposed.
    Thursday, July 05, 2012 6:18 PM