Validation of checkbox set - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Validation of checkbox set

Last post 02-04-2011 07:14 AM by tafavorite. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-23-2006 10:14 AM

    Validation of checkbox set

    i've got 6 checkboxes in the form and trying to set the condition via validation: If the First is checked (true), then atleast one more has to be selected. Could you help me to figure out how to do this? Thanks.
  • 05-23-2006 02:03 PM In reply to

    Re: Validation of checkbox set

    Hi Oleg and welcome to InfoPathDev!

    Have you tried to do this a rule in the first checkbox? You should be able to make a rule where you change the values of the checkboxes you want to select when the value of the first checkbox is = true.

    Hope that helps!
  • 05-24-2006 08:11 AM In reply to

    Re: Validation of checkbox set

    Thanks Ted,
    that's what i implemented, i guess this is the only way having dialog box pop-up and avoid writing a code. What i tried to have is - one of 5 check boxes 'required', if 6th is selected.
  • 05-25-2006 03:22 PM In reply to

    Re: Validation of checkbox set

    Actually this is quite easy to do but you need to know an xpath trick. Just set "Data Validation" on the first checkbox. Then your conditions are if the first checkbox is true but all the others are false, show an inline error. The trick is how many other checkboxes you have. InfoPath only allows you to specify up to 5 custom conditions, but you have 6 checkboxes! This is easy to work around though. Set the conditions as follows:

    if CB1, is equal to, true and
    CB2, is equal to, false and
    CB3, is equal to, false and
    CB4, is equal to, false and
    CB5, is equal to, false

    At this point you still need to add in the 6th checkbox. To do that:
    1) Go to the checkbox 5 condition
    2) Select the field selector dropdown and choose "The expression"
    3) you will now see the raw xpath expression underlying the pretty GUI
    4) copy the contents of that expression
    5) at the end of that expression type space then "and" with no quotes in lowercase. lowercase is critical for this operator (i found out the hard way). :)
    6) then type a space and paste in the first part that you copied.
    7) change the field name to the field name for your sixth field. This will look something like this now:
    ../my:field5 = string(false()) and ../my:field6 = string(false())

    8) type in the Screen Tip something like "You must select at least one additional item below along with this item."
    9) Click ok a few times.
    10) Preview the solution.

    Now when you check the first box you will get a validation error on that box until you select at least one other box.
    Shiraz Cupala / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 02-04-2011 07:14 AM In reply to

    Re: Validation of checkbox set

    Do you do that process for every check box then? so in your example CB 1 is true the rest are false, how would CB 2 look?: CB 2 = true, cb 3, cb 4 = false...?

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.