If you have to make some kind of validation where if one checkbox is checked there other should not be able to be checked or if you check a specific one the others or some other specific ones should be disabled then you can do this with some simple Javascript / jQuery

These fields that we want to control have an id and also a more specific name, but just in my case you of course can change it as you want/need.

<div class=”col-lg-8 data” style=”height: 270px;”>
<div class=”checkbox”>
<label>
<input name=”name”  value=”1″ checked=”” class=”someclass” id=”first” type=”checkbox”>
first      </label>
</div>

<div class=”checkbox”>
<label>
<input name=”name” value=”2″ class=”someclass” id=”second” type=”checkbox”>
second      </label>
</div>

<div class=”checkbox”>
<label>
<input name=”name” value=”3″ class=”someclass” type=”checkbox”>
something       </label>
</div>

<div class=”checkbox”>
<label><input name=”name” value=”4″ class=”someclass” type=”checkbox”>
something      </label>
</div>

<div class=”checkbox”>
<label><input name=”name” value=”5″ class=”someclass” type=”checkbox”>
something       </label>
</div>
<div class=”checkbox”>
<label><input name=”name” value=”6″ class=”someclass” id=”fourth” type=”checkbox”>
fourth        </label>
</div>

<div class=”checkbox”>
<label><input name=”name” value=”29″ class=”someclass” id=”fifth” type=”checkbox”>
fifth      </label>
</div>

<div class=”checkbox”>
<label>
<input name=”name” value=”11″ class=”someclass” type=”checkbox”>
something       </label>

</div>

<div class=”checkbox”>
<label><input name=”name” value=”7″ class=”someclass” type=”checkbox”>
something       </label>
</div>

</div>
</div>

in this example we are disabling the fourth and fifth fields if either the first or the second fields are checked or we check them. or vise versa as well if the fourth or the fifth fields are checked we are disabling the first and second fields.

$( document ).ready(function() {
if($(‘#first, #second’).is(“:checked”)){
$(‘#fourth’).attr(‘disabled’, true);
$(‘#fifth’).attr(‘disabled’, true);
} else if ($(‘#fourth, #fifth’).is(“:checked”)){
$(‘#first’).attr(‘disabled’, true);
$(‘#second’).attr(‘disabled’, true);
}
});

$(‘#first, #second’).change(function () {
if ($(this).is(“:checked”)) {
$(‘#fourth’).attr(‘disabled’, true);
$(‘#fifth’).attr(‘disabled’, true);
} else if($(‘#first, #second’).is(“:checked”)){
$(‘#fourth’).attr(‘disabled’, true);
$(‘#fifth’).attr(‘disabled’, true);
}
else {
$(‘#fourth’).attr(‘disabled’, false);
$(‘#fifth’).attr(‘disabled’, false);
}
});

//check if fourth is checked disable first
$(‘#fourth, #fifth’).change(function () {
if ($(this).is(“:checked”)) {
$(‘#first’).attr(‘disabled’, true);
$(‘#second’).attr(‘disabled’, true);
} else if ($(‘#fourth, #fifth’).is(“:checked”)){
$(‘#first’).attr(‘disabled’, true);
$(‘#second’).attr(‘disabled’, true);
}
else {
$(‘#first’).attr(‘disabled’, false);
$(‘#second’).attr(‘disabled’, false);
}
});

11/12/2017

Disable other checkbox-es if one is checked

If you have to make some kind of validation where if one checkbox is checked there other should not be able to be checked or if […]
21/11/2017

Export table to PDF and other formats with Javascript using tableExport.jquery.plugin

In this Article I’ll show you how to export tables using a js plugin called tableExport.jquery.plugin wich you can download from github. this plugin allows you to […]
08/11/2017

Change an input field using a url get request with parameters

What it really means is we are pressing an button which sends an argument threw the URL and based on the URL we change a drop-down […]
27/10/2017

Generate a link dynamically

If you have a form or whatever where you need to call a uri you can do it dynamically with the action Methode. lets imagine we […]
20/10/2017
laravel-cookies-large

Working with cookies Laravel

Laravel version 5.5 This article explains how to save cookie data to a browser and show them to the fronted. The controller – in our example […]