How to forbid unchecking checkbox's element?

Is it possible to forbid some action on checkbox? For example I want to leave $('#post-id') and $('#activation') checkboxes always checked, without any possibilities to uncheck them?

$("#activation").attr("checked", true);
$("#post-id").attr("checked", true);

My example you can find here: https://jsfiddle.net/9LzLm9hx/1/

Answers


You can use like this

      $( '#common' ).on('click', function () {
        $( '.common-inputs [type="checkbox"]:not([disabled])' ).prop('checked', this.checked); 
      });

//checkbox
            $("#activation").attr("checked", true);
      $("#post-id").attr("checked", true);
      $("#activation").attr("disabled", true);
      $("#post-id").attr("disabled", true);

You can simply add disabled to the checkboxes in question. They then have their default value, however, will not be editable anymore.

These are the changes in question:

<input type="checkbox" id="activation" name="check" disabled/>

This would be your updated jsfiddle: https://jsfiddle.net/9LzLm9hx/2/

Enjoy :)


You can use this code snippet after checked true.

<script>
function HideandDisabled(){
    $("#activation").attr("checked", true);
    document.getElementById("activation").disabled=true;
    $("#post-id").attr("checked", true);
    document.getElementById("post-id").disabled=true;
}
</script>

Need Your Help

Google app engine for static files in joomla

php google-app-engine joomla

hi i want to use google app engine for the static data for my joomla website currently my site is http://webkul.com i want to put all the css and js files in the app engine please help i am using g...