Only allow one checkbox to be selected

I have two checkboxes and I want them to start of unchecked. but if select one, and then choose to change your mind and select the other box, then the previous one goes unchecked. My code so far is below, I am so close. But when I run my app when you select one they both turn on or off. Please help.

    private void customer_IsCheckedChanged(object sender, EventArgs e)     {         if (business.IsChecked == true)         {             business.IsChecked = !customer.IsChecked;         }          if (business.IsChecked == false)         {             business.IsChecked = !customer.IsChecked;         }      }      private void business_IsCheckedChanged(object sender, EventArgs e)     {         if (customer.IsChecked == true)         {            customer.IsChecked = !business.IsChecked;         }          if (customer.IsChecked == false)         {             customer.IsChecked = !business.IsChecked;         }     } 

How to clear the publish checkbox in form or form element validation

I have a D8 form where when a test involving the value of other fields fails, if the publish (field = status) checkbox has been checked the validation should fail and the checkbox should be cleared when the form with error message is re-displayed.

I have made numerous attempts in permutations of custom callback for #validate, #element_validate and #value_callback, as set dynamically by hook_form_alter, using set(), setValue(), setValueForElement(), etc.

while the function fires in each case, and the setErrorByName() call works in each, in no case is the Publish checkbox cleared when the form reloads.

Javascript (Vanilla) – Check different values , and more values if a checkbox is checked

i want to get sure, that all fields are filled till the user gets to the next part of the form. If he checked “create account” the password fields are allso required. So i tried to proof this with a if statemant inside the function:

function checkit() { inputtx = document.getElementById(‘firstname’); inputlast = document.getElementById(‘lastname’);

 if (  inputtx.value.length == 0 ||  inputlast.value.length == 0    if (createcheck.checked == true){  ||  pwdone.value.length == 0 ||      pwdtwo.value.length == 0  


 )   {       alert("message");            return false;    }        return true;  }  

Does saving a file to temp and deleting whenever a checkbox is toggled considered a wise choice?

Me and my team have this Desktop client developed in JavaFX. It basically has a “Remember my password” checkbox. If the user ticks this checkbox, reboots, and reopens the app, the user should be automatically logged in. I’m using a cheap trick just saving a temp file to the temp directory. It’s encrypted and it contains the information required for this feature. It just checks if certain info is present – if yes, login and go to dashboard.

Now what they want is if the user logs out (different from just closing the app) but ticked the checkbox beforehand, then the next time he opens the app the username and password will already be there. While I was thinking of a solution, my teammate suddenly pushes a fix to this problem. If the user ticks the checkbox, it saves the info (rewrites the file) to the temp file. If the user un-ticks the checkbox, the file is deleted.

Is this a safe practice?

Add a CheckBox with a script

How can I use a script to add a CheckBox to a Sheet?

This is probaly trivial but I could not find a single example online and the CheckBox class isn’t even mentioned in the docs.

From the GUI, I would go Insert -> CheckBox.

Setting the value of the cell to either TRUE or FALSE doesn’t work.

Checkbox vs toggle

There’s a constant debate on checkbox vs toggle. enter image description here

Personally, as an iPhone and Mac owner, I’m still very confused every time when I see the toggle. I often ask ask myself, “The ‘on’ is on the left, does that mean I have to slide the light gray from right to left in order to turn it on?” I eventually found out the answer was no. Yet, I still have to mind exercise every time when I see the toggle.

Aside from personal feelings, what are the good arguments for using checkboxes vs toggles?

django-crispy-forms Agregar atributo a un checkbox de un CheckboxSelectMultiple

Estoy trabajando con django-crispy-forms y necesito agregar el atributo data-price a un checkbox. Estoy sobreescribiendo el método create_option() de la clase CheckboxSelectMultiple, pero esto solo funciona si no uso django-crispy-forms.

class CustomCheckboxSelectMultiple(forms.CheckboxSelectMultiple):      def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):         option = super().create_option(name, value, label, selected, index, subindex=None, attrs=None)         option['attrs']['data-price'] = value         return option   class ProductForm(forms.ModelForm):     class Meta:         model = Product         fields = '__all__'      def __init__(self, *args, **kwargs):         super().__init__(*args, **kwargs)          #  campo adicional que no corresponde al modelo         self.fields.update({             'categories': ModelMultipleChoiceField(                 label=None,                 queryset=Category.objects.all(),                 required=False,                 widget=CustomCheckboxSelectMultiple             )         })          self.helper = FormHelper() 

Usage of switch box, checkbox or radio button for a visibility flag


I have a visibility flag against document attached to a student profile. Administrator is the persona of Student profile. Administrator manages student profile and in the student profile we have a section of documents. Administrators can add student documents and they have the privilege to set it visible to student or not.


enter image description here


Now as you people have gone through the interaction, you must be able to figure out that the checkbox control of visibility becomes enabled when we select a document.

Our team is not convinced on having two check boxes in one one row. Should I be using a radio selection button or a toggle switch? Or maybe try to change the icon of visibility flag from checkbox icon to eye icon?

Variations I’ve implemented

enter image description here

But this was also rejected as it was too overwhelming in the row.

Kindly suggest some solution. Thanks !!!