Evaluate values for checkboxes

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Evaluate values for checkboxes

nelldores
Hi,

I have a form which uses the multiple checkboxes as shown below.

Option 1 - 1
Option 2 - 2
Option 3 - 3
Option 4 - 4

Now, if we need to have a validation such as only allow options which have
any combination that includes 1,2,3 but not along with 4, I had to write
several if conditions, where I am checking all possible patterns such as 1,
1 2, 2 1, 1 2 3, 3 2 1 etc.,

Surely, there must be a better way to do this?

Regards,
Nelson

--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Evaluate values for checkboxes

Erik Bruchez
Administrator
Nelson,

Use the following validation formula:

    xxf:split() = ('1', '2', '3') and not(xxf:split() = '4')
    or not(xxf:split() = ('1', '2', '3'))

Or even:

    let
        $values := xxf:split(),
        $has123 := $values = ('1', '2', '3')
    return
        $has123 and not($values = '4')
        or not($has123)

-Erik


--
Sent from: http://discuss.orbeon.com/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].