Hi Team,
In check box the option for making mandatory field as true is not available , hence how to implement the mandatory check.
Hi @R.kar ,
it depends on what you mean by 'mandatory'.
Is it mandatory for the user to check it (judging by the name of your checkbox, I think that's what you are after)? Then that is simply a custom validation on the value being true.
If you mean it is mandatory to make a choice between 2 options, than a regular checkbox with a regular boolean behind it can't really do much for you. There are only 2 options, and one of those (usually the false) is also the default, and Outsystems doesn't distinguish between default value or chosen value of false.
Dorine
Hi R.kar,
You need to do the checking in form submit action, simply use a if condition to check if your checkbox variable is True, In your case, should be Customer.Characteristi......
Then assign the widget valid to false which should be DigitalConsent.Valid if the checkbox variable is not equal to True before the Form.Valid checking.
Hope this help.
Hi R.Kar,
As Dorine mentioned you'll have to add this validation yourself according to what it is you want to achieve. You can add a client action to the checkbox where you check the value of the checkbox when selected/unselected or you can have a validation in your screen that checks if the checkbox is selected before leaving the page for example.
If you can provide further details about the purpose of this checkbox we can provide you with a more detailed explanation on how to implement it.
Another option for this is to use Radio Buttons , with Yes or no Options store the results as a text which allow a user to be made to choose a decision
I also tried to make the checkboxes in my app required, in plain HTML this is very simple and straightforward, here it took me a little bit of digging. This is what I found out so far:There are two ways to mark the checkbox as mandatory:1 - Select the checkbox -> go to Atributes -> add atributed "required" and set the value to "True" (as you would in plain HTML)2 - go to sumbittion button logic, before "Form.Valid?" insert if block and check if the corresponding local variable is set to false, if so lead to new assign block, where "Checkbox_NameOfYourCheckxox.Valid" = False and "Checkbox_NameOfYourCheckxox.ValidationMessage" = (to your custom message) That does it, but I still has some issues with styling to make it just as visible to the user as other mandatory fields when they have a warning. To replicate that effect I had to: in Themes edit the AppName (this is your app name) theme and add the folowing css:/* check boxes with custom warnings styles */ [data-checkbox].not-valid:before{ border-color: red;}[data-checkbox].not-valid ~ .validation-message { bottom: -20px; left: 5px;}div:has([data-checkbox].not-valid):last-of-type{ padding-bottom: 25px;}you can tweak the values or add other custom behaviour. I leave images demonstrating part of method 2 and the end result. Hope this helps anyone else searching for this implementation.