Hello all,
I’ve created a demo project for learning purposes. In this project, I need to validate 5 checkboxes.
On button click, I’m using an expression to check the validation. However, the current logic passes even if only 1 checkbox is selected and the others are not.
What I need is: the condition should only pass if all 5 checkboxes are checked.
Any help or suggestions to correct the expression logic would be appreciated.
Thanks!
Hi @Max Musterman,
You need to create five separate Boolean variables, one for each checkbox (e.g., IsCheck1, IsCheck2, IsCheck3, IsCheck4, IsCheck5)
After, in the onChange event of each checkbox, set its variable to True OR False when the checkbox is checked.
IsCheck1 and IsCheck2 and IsCheck3 and IsCheck4 and IsCheck5 = True
This expression will return True if all five are checked.
Hope it helps.
Thank you.
Thank you for your fast answer.
You can create a local variable (Boolean) for each checkbox – for example: Check1, Check2, Check3, Check4, Check5.
Bind each checkbox's value to its respective variable.
Then, in the OnClick action of your button, use an If condition like:
Check1 and Check2 and Check3 and Check4 and Check5
Show a message to the user in the false branch : "Please select all checkboxes before continuing."
This will ensure that all checkboxes are selected before proceeding.
Hope this helps!
Thanks,
Supriya
Thank you for your reply.
Previous answers are correct by fellow developers but I think it is bad user experience to have 5 clicks mandatory, I would show a message with contrast color that on clicking saving you are agreeing this and that conditions and etc. this is better experience I think and then I would have attributes saved in db as True by default if you are saving them if not in structure, or I would create them as radion buttons default True and not editable, this way it wouldn't be nacessary to validate and they will be true by default and there will be no need for user interaction for this part
Hi Nino,
Thank you for your suggestion!
I’ve already created a variable to store the values of all checked boxes. However, in my case, the requirement is to have the user check each box one by one, because each checkbox is linked to specific terms that require user attention and agreement individually, so checking all at once isn’t allowed.
Still, I appreciate your input and will consider your approach for future use.
Thanks again for your reply!